Catch opencv exception

[tcp @ 0x5648d26a66a0] Connection to tcp://192.168.1.2:4747 failed: Connection refused
[ERROR:0] global /opt/opencv/modules/videoio/src/cap.cpp (162) open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.5.3-dev) /opt/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can’t find starting number (in the name of file): http://192.168.1.2:4747/video in function ‘icvExtractPattern’

i try to catch this exception ,it is failed .can any one help me in this.
thanks in advance…

show code, please :]

cv::VideoCapture cap(0);

#if PHONE_DEBUG
// Mobile camera ip address
std::string videoStreamAddress = “http://192.168.1.2:4747/video”;
cap.set(cv::CAP_PROP_FRAME_WIDTH, PHONE_DEBUG_FRAME_WIDTH);
cap.set(cv::CAP_PROP_FRAME_HEIGHT, PHONE_DEBUG_FRAME_HEIGHT);
try{
if(!(cap.open(videoStreamAddress))) {
if(getDebugLevel() > 0){
logText(“Can not open the camera for phone debug for
technical reasons. Please contact Anzo.\n”);
} return 0;
}
}
catch(cv::Exception& e)
{
// const char* err_msg = e.what();
std::cout << "exception caught: " << e.what() << std::endl;
}

1 Like