简体   繁体   中英

Segmentation fault using OpenCV with Node.js

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:

enter code here

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

Here is the code that produces the error when trying to run over a folder of images:

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
    }

  });
})

});

I sometimes get "can't read property length of udnefined" at faces.length but what I really want to solve is the segmentation fault. I already did some research and tried using different xml files for the opencv face detection and still no luck

I Had the same problem, and I solved handling the concurrent request to " .detectObject()

I mean, wait until the previous call to detectObject() finish.

In some cases, with better processors I don't have this problem, but in ARM I've solve that by doing that control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM