node-opencv
node-opencv copied to clipboard
convertGrayscale & detectObject = Unrecognized or unsupported array type in function cvGetMat
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/array.cpp, line 2482 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat
...
img_gray = img.copy()
img_gray.convertGrayscale()
img_gray.detectObject cv.FACE_CASCADE, {}, (err, faceRects) ->
same problem here, Ubuntu 15.04 with OpenCV 2.4.11
cv.ImageSimilarity
also doesn't seems to exists in my case.
I also have the issue cv.ImageSimilarity method not existing. It seems that we need OpenCV 3.0 for that but since i installed OpenCV with brew easily (and had some problems installing manually) going the other way seems scary to me. Although in the end i see no other solution.
Same issue with OpenCV 3.0. Did you find a solution?
Sometimes convertGrayScale() throws also this:
OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor, file /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/color.cpp, line 3959 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/color.cpp:3959: error: (-215) (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cvtColor
I ran into this problem as well (the detectObject()
one). It seems like detectObject()
is not happy if it is started again before the callback is triggered. Here's a way to get around this using a lock:
var cv = require('opencv');
var ReadWriteLock = require('rwlock');
var lock = new ReadWriteLock();
var camera = new cv.VideoCapture(0);
setInterval(function() {
camera.read(function(err, im) {
if (err) throw err;
lock.writeLock(function (release) {
im.detectObject('./node_modules/opencv/data/haarcascade_frontalface_alt.xml', {}, function(err, faces) {
if (err) throw err;
release();
});
});
});
}, 10);
Even with @gregfriedland's workaround, I'm still getting the same error here: https://github.com/werdnanoslen/funberry/blob/master/app.js
I'm still getting the same erro too! Im using the workaround too.