Created
December 3, 2018 22:59
-
-
Save dataslayermedia/29801e036b70c7bbbcfdbe77294f8329 to your computer and use it in GitHub Desktop.
ALPR License Plate Detection for Raspberry PI written in Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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