opencv_ffmpeg module crash (IP Camera)

asked 2016-11-25 07:20:56 -0500

Suraksha gravatar image

updated 2016-11-26 04:29:26 -0500

I'm using IP webcam android app(It converts mobile camera into IP web camera).
I'm running below code in Visual Studio 2015 with OpenCV 3.1.

VideoCapture cap; Mat img;
cap.open("http://192.168.0.101:8080/video?x.mjpeg");
while(waitKey(33)!=27)
{
    try{
        cap>>img;  //code crashes here
        if(img.empty())
        {
         cout<<"camera Closed"<<endl;
         break;
        }
         imshow("Video",img);
      } catch(...{}    
}

Getting below error. If the internet connection is slow or if the Wi-Fi is disconnected in my android device the program crashes
Error:

Exception thrown at 0x0BF2F6F0 (opencv_ffmpeg310.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000020.

If there is a handler for this exception, the program may be safely continued.

even if the code is wrapped within try catch block, it crashes!

Should I use try {} catch (...) block in source file, if yes, then where should I use this?
I referred this link but did not find the right answer.

edit retag flag offensive close merge delete

Comments

check if cap is opened using isOpened method before while loop

LBerger gravatar imageLBerger ( 2016-11-25 08:52:09 -0500 )edit

cap.IsOpened() always returns true even when Wi-Fi is turned off.

Suraksha gravatar imageSuraksha ( 2016-11-25 09:47:52 -0500 )edit