node-opencv
node-opencv copied to clipboard
Is BackgroundSubtractor ready to use?
Hi,
I'm trying to make BackgroundSubtractor work, since it is not initiated out of box.
First of all, I initiated it from src/init.cc and run npm install --build-from-source (node-gyp throws error which I can't understand so far)
And I briefly made a test code to check whether it works.
Here is the code I used:
var cv = require('opencv');
var bg = new cv.BackgroundSubtractor();
cv.readImage('./1.jpg', function(err, im) {
if(err) throw err;
cv.readImage('./2.jpg', function(err, im2) {
bg.applyMOG(im, im2);
});
});
but no luck. it doesn't work.
home/share/GIT/VSN/Nodejs/test4/test.js:7
bg.applyMOG(im, im2);
^
TypeError: Argument 1 must be a function
at /home/share/GIT/VSN/Nodejs/test4/test.js:7:6
at /home/share/GIT/VSN/Nodejs/test4/test.js:6:5
at Object.
unfortunately I'm not that much familiar with node.js so hard to figure out what is wrong with it.
Am I digging a wrong hole?
I got the same problem... Did you resolve it?
It looks from the code like the second argument should be a callback, which will receive the foreground mask. This makes sense for Node.js, although this seems syncronous - so would be easier to just return it... Anyway, when changing to use a callback, you may still run into https://github.com/peterbraden/node-opencv/issues/305
Any luck with this issue?