Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zilahir/579882ada2565a3d24e40d3d68e2e2d3 to your computer and use it in GitHub Desktop.
Save zilahir/579882ada2565a3d24e40d3d68e2e2d3 to your computer and use it in GitHub Desktop.
ALPR License Plate Detection for Raspberry PI written in Node.js
const PiCamera = require('pi-camera');
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
setInterval(function() {
var path = './' + getRandomInt(500) + '.jpg';
const myCamera = new PiCamera({
mode: 'photo',
output: path,
width: 1920,
height: 1080,
nopreview: false,
});
myCamera.snap()
.then((result) => {
var exec = require('child_process').exec;
var cmd = 'alpr -c us -n 1 --json ' + path;
exec(cmd, function(error, stdout, stderr) {
var data = JSON.parse(stdout);
if (data.results.length > 0) {
console.log(data.results[0].plate);
} else {
console.log("\n\n\nNo license plate found.\n\n");
}
});
console.log(result);
})
.catch((error) => {
console.log(error);
});
}, 2e3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment