首页 文章

使用nodejs中的zbarcam

提问于
浏览
0

我正在尝试使用zbarcam来监控USB凸轮并拍摄它看到的QR码 .

我是Zbarcam和Nodejs的新手,但做了大量研究,看不出有什么问题 . 我在Ubuntu 12.04 LTS上运行它,它在命令行中工作正常,但是当在Node中的子进程中运行时,它什么都不返回 .

如果我在命令行上运行以下命令它工作得很好,看到QR码并回拍代码:

zbarcam /dev/video0 --prescale=1280x720 -q --raw --nodisplay

但是当我在一个小的nodejs脚本中运行它时,它只是挂起,我可以看到凸轮启用,但响应不会返回 .

var exec = require('child_process').exec,child;

    child = exec('zbarcam /dev/video0 --prescale=640x480 -q --raw --nodisplay', function (error, stdout, stderr) {
       if (error) {
         console.log(error.stack);
         console.log('Error code: '+error.code);
         console.log('Signal received: '+error.signal);
       }
       console.log('Child Process STDOUT: '+stdout);
       console.log('Child Process STDERR: '+stderr);
     });

     child.on('exit', function (code) {
       console.log('Child process exited with exit code '+code);
     });

我怀疑这是我在Node中启动它的方式以及节点如何跟踪stdout .

感谢所有提前 .

1 回答

相关问题