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

convertGrayscale & detectObject = Unrecognized or unsupported array type in function cvGetMat

Open vinnitu opened this issue 9 years ago • 7 comments

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) ->

vinnitu avatar Jun 15 '15 08:06 vinnitu

same problem here, Ubuntu 15.04 with OpenCV 2.4.11

cv.ImageSimilarity also doesn't seems to exists in my case.

didasy avatar Jun 29 '15 14:06 didasy

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.

kaanozcan avatar Jul 12 '15 13:07 kaanozcan

Same issue with OpenCV 3.0. Did you find a solution?

saccodd avatar Aug 05 '15 18:08 saccodd

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

saccodd avatar Aug 05 '15 19:08 saccodd

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);

gregfriedland avatar Aug 18 '15 01:08 gregfriedland

Even with @gregfriedland's workaround, I'm still getting the same error here: https://github.com/werdnanoslen/funberry/blob/master/app.js

werdnanoslen avatar Sep 21 '15 19:09 werdnanoslen

I'm still getting the same erro too! Im using the workaround too.

Judahh avatar May 08 '17 18:05 Judahh