node-opencv icon indicating copy to clipboard operation
node-opencv copied to clipboard

Is BackgroundSubtractor ready to use?

Open kdsoo opened this issue 9 years ago • 3 comments

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. (/home/share/GIT/VSN/Nodejs/test4/test.js:4:4) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:902:3

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?

kdsoo avatar Mar 19 '15 08:03 kdsoo

I got the same problem... Did you resolve it?

dinggnan avatar Apr 20 '16 15:04 dinggnan

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

jonnor avatar Dec 03 '16 15:12 jonnor

Any luck with this issue?

qbdumont avatar Mar 17 '17 17:03 qbdumont