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

trouble using meanStdDev()

Open jabadia opened this issue 10 years ago • 7 comments

Hi,

I'm having some trouble using meanStdDev() or meanWithMask()... can you please post an example of invocation of these methods?

Thanks!

jabadia avatar Mar 28 '15 20:03 jabadia

This?

var cv = require('./your/opencv');
cv.readImage('/path/to/image', function (err, mat) {
    var meanstddev = mat.meanStdDev();
    console.log(meanstddev);
});

doc-l avatar Jun 08 '15 11:06 doc-l

@l-hendriks Perhaps I'm doing something wrong, but

console.log(JSON.stringify(mat.meanStdDev()));

prints

{"mean":{},"stddev":{}}

Any idea what's up with that? There also doesn't seem to be a plain old mean() method, for whatever reason (though I actually am interested in the standard deviation for my application).

Nateowami avatar Sep 07 '16 11:09 Nateowami

I don't use node-opencv anymore unfortunately, but you should debug your mat object. I literally took that snippet out of working code.

doc-l avatar Sep 07 '16 16:09 doc-l

@l-hendriks I stuck it into a function where all sorts of transforms are successfully done on the matrix (including saving to file for debugging). So I know the matrix works. Then I stuck that line right at the top of the function, so the matrix couldn't have been "broken" or something farther down. My guess is that we're using different versions (node-opencv 5.0.0). Or does it require a single-channel image?

Nateowami avatar Sep 08 '16 11:09 Nateowami

It could do multichannel.

I was using an old version (running on node 0.12 at the time), so maybe that is the problem. We now use opencv using c++ and call the binary from node which works perfectly. You don't need this library and have access to the full opencv api that way.

doc-l avatar Sep 09 '16 06:09 doc-l

@l-hendriks Yeah... I may just have to do that. Unfortunately my C++ skills are terrible. So either an excuse to improve them or try using Python.

Are you able to shuffle images between your C++ program and Node.js without writing them to disk?

Nateowami avatar Sep 09 '16 07:09 Nateowami

No we don't do that, but our images are small so we don't really care.

doc-l avatar Sep 09 '16 08:09 doc-l