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

Catching Errors?

Open mooglin opened this issue 13 years ago • 6 comments

I came across this question when searching for an answer to a similar problem.

http://stackoverflow.com/questions/18646547/cant-catch-node-opencv-errors

Can you shed any light on this?

mooglin avatar Sep 09 '13 04:09 mooglin

yeah, like the comments say, I haven't added exception handling in the c++ code yet, so it's a bit of a crap shoot at the moment - do you have a particular scenario that you're running into these issues? I could probably add a try catch for that..

peterbraden avatar Sep 09 '13 08:09 peterbraden

Basically I need to send images to the server. It's possible some could be the wrong format or possibly just corrupt. When it fails to read the image (corrupt) or when it fails to use the image in object detection (wrong params) I'd like to respond to an error and keep processing images coming in rather then crash the process.

Thanks

mooglin avatar Sep 10 '13 06:09 mooglin

+1

d4nicoder avatar Oct 15 '13 21:10 d4nicoder

Could you add try catch for this error?

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /build/buildd/opencv-2.3.1/modules/core/src/array.cpp, line 2482
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.3.1/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat

My code is this:

if (fs.existsSync(ruta)) {
    //Vamos a escanear las caras
    cv.readImage(ruta, function(err, im){
        if (err){
            me.mg.mgConn.close();
            callback(err, null);
            return false;
        } else {
            im.detectObject(global.R + "/node_modules/opencv/data/haarcascade_frontalface_alt.xml", {}, function(err, faces){  
                if (err){
                    callback(err,null);
                    return false;   
                } else {
                    me.mg.mgConn.close();
                    callback(false, faces);
                }
            });
        }
    });
} else {
    me.mg.mgConn.close();
    callback("Fichero no encontrado", null);
    return false;
}

d4nicoder avatar Oct 17 '13 10:10 d4nicoder

Hi.

So we are about to go into production using this package. We're running into an issue where a crash in the C++ level code, kills our node process. PM2 restarts it gracefully, but it's hard to figure out where these crashes are.

Is there any plans for improving the error handling in the C++ bindings?

dbousamra avatar Aug 20 '14 06:08 dbousamra

Hi,

No immediate plans, as I haven't really got time at the moment to do this - it's definitely something that needs to be done, and I'd love to get it in, but I don't have a timetable for it at the moment.

Ideally it could be done with some macros so it would be easy to apply it across all the methods.

peterbraden avatar Aug 21 '14 07:08 peterbraden