Ask Your Question

Revision history [back]

Segmentation fault using OpenCV with Node.js

Hello, I am trying to detect faces on a series of images in a node script and I am getting a segmentation fault.

This is the output of the console when the error occurs:

  OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /tmp/opencv-20160626-26273-1a7s2xo/opencv-2.4.13/modules/core/src/array.cpp, line 2482
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /tmp/opencv-20160626-26273-1a7s2xo/opencv-2.4.13/modules/core/src/array.cpp, line 2482
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /tmp/opencv-20160626-26273-1a7s2xo/opencv-2.4.13/modules/core/src/array.cpp, line 2482
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /tmp/opencv-20160626-26273-1a7s2xo/opencv-2.4.13/modules/core/src/array.cpp, line 2482
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /tmp/opencv-20160626-26273-1a7s2xo/opencv-2.4.13/modules/core/src/array.cpp, line 2482
Segmentation fault: 11

This is the code that produces the error:

glob.sync('*.jpg' ).forEach( function( file,index,array ) {

cv.readImage(file, function(err, im){
    im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){
        if(faces.length>0){

            //do something

        }
        else{

            //do another thing
        }

      });
    })

});