1

我正在使用 openalpr 和带有 node.js 的树莓派 3 进行项目。

我已经编译了 OpenAlpr 并从命令行工作,现在我正在尝试使用 node-openalpr 模块从图像中识别车牌并找到下一个结果:

以root身份运行程序:

pi@raspberrypi:~/nodeopenalpr $ sudo node index.js
Before Start.
Start:  true
Before getting version
version:  2.2.4
Before loop:  0
Before IdentifyLicense Execution
pi@raspberrypi:~/nodeopenalpr $

以当前用户身份运行程序:

pi@raspberrypi:~/nodeopenalpr $ node index.js
Before Start.
Start:  true
Before getting version
version:  2.2.4
Before loop:  0
Before IdentifyLicense Execution
working
exception in identify method:  ReferenceError: identifyResult is not defined
    at identify (/home/pi/nodeopenalpr/index.js:19:38)
    at Object.<anonymous> (/home/pi/nodeopenalpr/index.js:36:3)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Function.Module.runMain (module.js:575:10)
    at startup (node.js:160:18)
    at node.js:456:3
After loop:  0
Before loop:  1
Before IdentifyLicense Execution
Segmentation fault
pi@raspberrypi:~/nodeopenalpr $

我使用的软件版本如下:

  • OpenAlpr (v2.2.4 最难编译)
  • Node.js (v6.2.1)
  • npm (v3.9.3)

这是我正在运行的代码:

        // statements
var openalpr = require ("node-openalpr");
//console.log("OPENALPR: ", openalpr);

function identify (id, path) {
    try {
        // statements
        console.log("Before IdentifyLicense Execution");
        console.log(openalpr.IdentifyLicense (path, function (error, output) {
            console.log("Finish IdentifyLicense. Output: ", output);
            console.log("Finish IdentifyLicense. Error: ", error);
            var results = output.results;
            console.log (id +" "+ output.processing_time_ms +" "+ ((results.length > 0) ? results[0].plate : "No results"));

            if (id == 349) {
                console.log (openalpr.Stop ());
            }
        }));
        console.log("After plate identification: ", openalpr);
    } catch(e) {
        // statements
        console.log("exception in identify method: ", e);
    }
}

try {
    console.log("Before Start.");
    console.log("Start: ", openalpr.Start ("/usr/local/share/openalpr/config/openalpr.defaults.conf", "/usr/local/share/openalpr/runtime_data", 4,true));

    console.log("Before getting version");
    console.log("version: ", openalpr.GetVersion ());

    for (var i = 0; i < 350; i++) {
        console.log("Before loop: ", i);
        identify (i, "/home/pi/nodeopenalpr/lp.jpg");
        console.log("After loop: ", i);
    }
} catch(e) {
    // statements
    console.log("Exception captured: ", e);
}

我试图弄清楚这个好几次。我将非常感谢您的帮助。

赫克托

4

0 回答 0