node-opencv
node-opencv copied to clipboard
trouble using meanStdDev()
Hi,
I'm having some trouble using meanStdDev() or meanWithMask()... can you please post an example of invocation of these methods?
Thanks!
This?
var cv = require('./your/opencv');
cv.readImage('/path/to/image', function (err, mat) {
var meanstddev = mat.meanStdDev();
console.log(meanstddev);
});
@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).
I don't use node-opencv anymore unfortunately, but you should debug your mat object. I literally took that snippet out of working code.
@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?
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.
@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?
No we don't do that, but our images are small so we don't really care.