Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Opencv IP Camera Error

I am using andriod app (IP webcam) as ip camera. i'm running below code in separate thread. because if i run in main thread it crashes the program.

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

everything works fine. even if i turn off camera(close andriod app) it prints "Camera closed" in Console. The problem occurs when i turn off wifi on my andriod device. the moment i turn off wifi directly(having app still running) thread freezes, even though its in try catch block!

i have a button_click event in my form and i'm callingcap.release(); in it. if i click this button then, follow error is displayed in visual studio (no error from opencv)

HEAP[Test.exe]: HEAP: Free Heap block 6797780 modified at 67977d4 after it was freed Windows has triggered a breakpoint in Test.exe.
This may be due to a corruption of the heap, which indicates a bug in Test.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Test.exe has focus.
The output window may have more diagnostic information.

Have anybody come across this error? Visual Studio debugger stops at cap.release(); line

Is there a way to overcome this issue?

Thanks & Regards

P.S: I'm using Visual Studio 2013 with opencv 3.0 [C++/Cli (winforms)]