Opencv IP摄像头错误 [英] Opencv IP camera error

查看:225
本文介绍了Opencv IP摄像头错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用andriod app(IP网络摄像头)作为ip camera。我在单独的线程中运行代码。因为如果我在主线程中运行它会导致程序崩溃。



 VideoCapture cap; Mat img; 
cap.open( http://192.168.0.101:8080/video?x.mjpeg< /跨度>);
while (waitKey( 33 )!= 27
{
尝试 {
cap>> img;
cout<< 线程有效<< endl;
if (img.empty())
{
cout<< camera Closed<< endl;
break ;
}
imshow( 视频,img);
} catch (... {}
}





一切正常。即使我关闭相机(关闭andriod应用程序)它在控制台打印相机关闭。当我关闭我的andriod设备上的wifi时出现问题。我直接关闭wifi的那一刻(有应用程序仍在运行)线程冻结,即使它在try catch块中!



i在我的表单中有一个button_click事件,我正在调用cap.release();在其中。如果我点击此按钮,则会在visual studio中显示以下错误(opencv没有错误)



 HEAP [Test.exe ]:HEAP:免费堆块 6797780 在被释放后在67977d4处被修改Windows已在Test.exe中触发断点。

这可能是由于堆的损坏,这表示Test.exe或它已加载的任何DLL中的错误。

这也可能是由于用户按下F12 while Test.exe具有焦点。

输出窗口可能包含更多诊断信息。





有没有人遇到过这个错误?

Visual Studio调试器在cap.release停止(); line



有没有办法解决这个问题?



谢谢&问候



PS:我正在使用Visual Studio 2013和opencv 3.0 [C ++ / Cli(winforms)]



我尝试了什么:



带帽的崩溃.~VideoCapture();在button_clickEvent中。但是没有崩溃img.release();

解决方案

如果您阅读并理解错误消息,它告诉您真相:您曾经处理过被劫持的内存。



这种文本是发现问题的黄金路径。这样的错误文本后学习谷歌!!!



你不能重启一个帖子,因为它是一个僵尸。释放对象并创建所有对象的新实例! (如有必要,重新编写代码)



请阅读并尝试理解 C动态内存分配。这听起来很傻,但它是如何运作的。按照一些链接并将其加入书签。在某些月份你可能会理解它。 ; - )

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

What I have tried:

Crash occurs with cap.~VideoCapture(); in button_clickEvent. But no crash on img.release();

解决方案

If you read and understand the error message it told you the truth: you worked on barbaged memory.

Such textes are the golden trail for finding the problems. Learn to Google after such error textes!!!

You cant "restart" a thread, because it is a "Zombie". Free the objects and reate new instances of all objects!!! (re-write the code if necessary)

Please read and try to understand C dynamic memory allocation. It sounds silly, but it is how it works. Follow some of the links and bookmark it. In some months you may understand it. ;-)


这篇关于Opencv IP摄像头错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆