trying to disable VIDEOIO ERROR message

asked 2019-09-18 21:10:24 -0600

gino0717 gravatar image

I'm making a sample function to detect whether the webcam is plugged in the USB or not like:

VideoCapture video(-1);
Mat frame;
if( frame.cols>0)
    cout<<"camera's back!"<<endl;

It's all work fine but it would output the following message if no camera here

VIDEOIO ERROR: V4L: can't find camera device

I don't want to show the opencv error message in my own program so I write this:

int handleError( int status, const char* func_name,
            const char* err_msg, const char* file_name,
            int line, void* userdata )
    return 0; 

and put the


before the VideoCapture but noting happened. I also tried cvSetErrMode(2) (not good but I cannot find the current version of this function) and still, nothing happened.

How do I disable the VIDEOIO ERROR message?

edit retag flag offensive close merge delete