Ask Your Question
1

Opencv IP Camera Error

asked 2016-06-21 03:58:05 -0600

Prakash gravatar image

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)]

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2017-04-11 01:35:40 -0600

Suraksha gravatar image

Compilethe latest version from github OpenCV (Master branch). It works fine.

edit flag offensive delete link more
0

answered 2017-04-11 05:18:27 -0600

deepmore gravatar image

when u close the wifi it's totally normal for it to crash because you're using an ip camera !! without wifi you will have no access on it.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-21 03:58:05 -0600

Seen: 845 times

Last updated: Apr 11 '17