-
Notifications
You must be signed in to change notification settings - Fork 0
openalpr
車牌辨識 Kurento 的車牌辨識只是個學生的測試,而且只適合歐洲車牌。 目前比較能用的是 openALPR https://github.com/openalpr
在 ubuntu 14.04 中安裝: wget -O - http://deb.openalpr.com/openalpr.gpg.key | sudo apt-key add - echo "deb http://deb.openalpr.com/master/ openalpr main" | sudo tee /etc/apt/sources.list.d/openalpr.list sudo apt-get update sudo apt-get install openalpr openalpr-daemon openalpr-utils libopenalpr-dev
$ cat alpr.js var tmp_path = '/tmp/alpr'; var counter = 7; // alpr will be triggered after every counter.
const cp = require("child_process");
cp.exec("rm -Rfv " + tmp_path + "; mkdir -pv " + tmp_path);
var ffmpeg = cp.spawn("ffmpeg",['-y','-loglevel', 'debug','-i', "rtsp://192.168.0.103/live2.sdp", '-r', '1', '-f', 'image2', '-strftime', '1', '/tmp/alpr/alpr_%Y%m%d-%H%M%S.jpg']);
ffmpeg.stderr.on('data', function (data) { });
ffmpeg.on('close', function (code) { console.log('ffmpeg child process exited with code ' + code); });
var iw = cp.spawn("inotifywait",['--monitor', tmp_path, '--event', 'CLOSE_WRITE,CLOSE', '--format', '%f']);
iw.stdout.on('data', function (data) { //console.log('stdout: ' + data); if (counter <= 0) { alpr(tmp_path + '/' + data, function (plates) { console.log(plates); }); counter = 7; } else { counter--; } });
iw.stderr.on('data', function (data) { console.log('stderr: ' + data); });
iw.on('close', function (code) { console.log('inotifywait child process exited with code ' + code); });
var alpr = function (filename) { cp.exec("alpr --json " + filename, function (error, stdout, stderr) { var j = JSON.parse(stdout); for (var i in j.results) console.log(j.results[i]); cp.exec("xloadimage -delay 1 -zoom 30 " + filename);
if (error !== null) {
console.log('exec error: ' + error);
process.exit(99);
}
}); }
openalpr 目前沒有台灣車牌,但可以用既有國家偵測台灣車牌,若要提高識別率,則要重新訓練。訓練程式如下:
https://github.com/openalpr/train-ocr https://github.com/openalpr/train-detector
You need a few thousand cropped plate images (at the same aspect ratio) to do the detector training. OCR training can be completed with 100 or so cropped images.
已經有人訓練出新加坡車牌 https://groups.google.com/forum/#!topic/openalpr/oWU2CvTR7yU