本文介绍了Opencv_ffmpeg模块崩溃(IP摄像头)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用IP网络摄像头Android应用程序(它将移动摄像头转换为IP网络摄像头)。我在Visual Studio 2015中使用OpenCV 3.1运行代码。 VideoCapture上限; Mat img; cap.open( http://192.168.0.101:8080/video?x.mjpeg); while (waitKey( 33 )!= 27 ) { 尝试 { cap>> img; // 代码崩溃 if (img.empty()) { cout<< camera Closed << ENDL; break ; } imshow( 视频,img); } catch (... {} } 获取以下error.c如果互联网连接速度很慢或者我的Android设备断开了Wi-Fi程序崩溃 错误: test.exe中的0x0BF2F6F0(opencv_ffmpeg310.dll)抛出异常:< br /> 0xC0000005:访问冲突读取位置0x00000020。< br /> < br /> 如果有这个例外的处理程序,程序可以安全地< br /> 续。 即使代码包裹在try catch块中,它崩溃了! 我应该在源文件中使用try {} catch(...)块,如果是,那么我应该在哪里使用它? 我的尝试: 我推荐此链接链接但未找到正确的答案。解决方案 通常,在此代码,在开始时,你声明两个变量: VideoCapture cap; Mat img; 您通常通过调用 cap.open( http://192.168.0.101:8080/video?x.mjpeg); 方法然后执行循环以从存储它们的摄像机设备中检索每个帧由 Mat img 对象表示的帧矩阵。在下一个循环的第一次迭代中,您通常使用 cap 对象句柄从摄像机流中检索第一帧并将其存储到矩阵 IMG 。 *但是,对于下一次迭代,您使用相同的对象 img 这不是空的,包含前一帧的矩阵。这就是为什么在我看来你的应用程序崩溃了,因为你需要在循环执行期间为每个帧提取一个空矩阵。尝试在下面的循环范围内声明 Mat img 对象,如下所示: VideoCapture上限; cap.open( http://192.168.0.101:8080/video?x.mjpeg); while (waitKey( 33 )!= 27 ) { 尝试 { Mat img; cap>> img; // 代码崩溃 if (img.empty()) { cout<< camera Closed << endl;<! - newline = - = > break ; } imshow( 视频,img); } catch (... {} }< / endl;<! - > 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.cIf the internet connection is slow or if the Wi-Fi is disconnected in my android device the program crashesError: Exception thrown at 0x0BF2F6F0 (opencv_ffmpeg310.dll) in test.exe:<br /> 0xC0000005: Access violation reading location 0x00000020.<br /> <br /> If there is a handler for this exception, the program may be safely<br /> 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?What I have tried:I referred this link link but did not find the right answer. 解决方案 Normally, in this code, at the beginning, you declare two variables: VideoCapture cap; Mat img; You normally open the camera by invoking cap.open("http://192.168.0.101:8080/video?x.mjpeg"); method and then perform a loop to retrieve each frame from the camera device storing them into a frame matrix represented by Mat img object. During the first iteration of the following loop you just normally retrieve the first frame from the camera stream by using cap object handle and store it into the matrix img. *BUT* for the next iterations you use the same object img which is not empty containing the previous frame's matrix. That's actually why, in my opinion, your application crashes since you need to an empty matrix for each frame fetch during the loop execution. Try to declare the Mat img object in the scope of the following loop the way I've shown below:VideoCapture cap; cap.open("http://192.168.0.101:8080/video?x.mjpeg"); while(waitKey(33)!=27) { try{ Mat img; cap>>img; //code crashes here if(img.empty()) { cout<<"camera Closed"<<endl;<!-- newline="" --=""> break; } imshow("Video",img); } catch(...{} }</endl;<!--> 这篇关于Opencv_ffmpeg模块崩溃(IP摄像头)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 02:30
查看更多