0
votes


I am trying to use zbarcam to monitor the usb cam and shoot back the QR Codes it sees.

I am new to both Zbarcam and Nodejs, but have done a fair amount of research and cannot see what is wrong. I am running this on Ubuntu 12.04 LTS and it works fine from the command line, but when run in a child process in Node it returns nothing.

if I run the following on the command line it works great, sees the QR Codes and shoots back the code:


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

but when I run it in a small nodejs script it just hangs, I can see the cam enable, but the response does not route back.


    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);
     });

I suspect it's the way I start it in Node and how node tracks the stdout.

Thanks to all in advance.

1

1 Answers

0
votes

you can use the zbar npm, here's my fork on github https://github.com/flatr0ze/node-zbar with updated readme file

run npm install zbar and follow the readme, it should work fine

here's an Npm-less example: https://github.com/cloudpower/qr2wifi/blob/f28f3bf7062b58c8adca2751faaf4e070fa124b4/index.js

good luck!