OpenCV2.4.2 VideoAccess的未处理异常 [英] OpenCV2.4.2 unhandled exception on VideoCapture

查看:1719
本文介绍了OpenCV2.4.2 VideoAccess的未处理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了OpenCV2.4.2并使用CMake创建了一个OpenCV项目。我没有得到任何编译错误。我有几个函数用于处理图像,我有2个应用程序:



1-处理视频中的数据



2-处理模拟数据。



除了从视频中提取数据之外,两个应用程序都是相同的。



strong> PROBLEM :应用程序处理视频时崩溃


程序中0x75d8a048处的未处理异常access.exe访问违例
阅读位置0x049f08c0。


当阅读框架时,此部分代码崩溃:

  cv :: VideoCapture _video; 
while(1)
{
//抓取框架
_video>>帧; < ------------- CRASHES HERE
processFrame(frame);
}

所以我想可能有一个问题 cv :: VideoCapture 类在OpenCV 2.4.2。如何检测问题并解决问题?



编辑



相机我设法捕获错误消息:

  OpenCV错误:声明失败(m.dims> = 2) ,file ..\..\..\ 
src\opencv\modules\core\src\matrix.cpp,第268行
OpenCV错误:断言失败(0 < = _rowRange.start&& _rowRange.start< = _rowR
ange.end&& _rowRange.end< = m.rows)未知函数,file .. \..\\ \\..\src\open
cv\modules\core\src\matrix.cpp,第283行

$您是否正在检查捕获是否实际打开了文件/相机?

 >  if(_video.isOpened()){//检查捕获是否成功
//做stuff
}

默认情况下并不支持所有编解码器。这取决于您在下面用于打开视频的库。 (这可能是ffmpeg或quicktime)。



也可以自己捕获异常,只是为了安全方面的未来问题

  try {
_video>>帧;
} catch(cv :: Exception){
cout<< 一个例外已经精确< endl;
};


I just installed OpenCV2.4.2 and created an OpenCV project using CMake. I don't get any compilation errors. I have several functions for processing images and I have 2 applications:

1- Processes data from a video

2- Processes simulated data.

Both applications are identical except from the data extraction from the video.

PROBLEM: The application processing video crashes with

Unhandled exception at 0x75d8a048 in program.exe Access violation reading location 0x049f08c0.

It crashes in this part of the code, when reading frames:

cv::VideoCapture _video;
while(1) 
{       
        // grab the frame
        _video >> frame;  <-------------CRASHES HERE
                processFrame(frame);
}

So I guess there could be a problem with cv::VideoCapture class in OpenCV 2.4.2. How can I detect the problem and solve it?

EDIT

With video camera I managed to catch the error message:

OpenCV Error: Assertion failed (m.dims >= 2) in unknown function, file ..\..\..\
src\opencv\modules\core\src\matrix.cpp, line 268
OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowR
ange.end && _rowRange.end <= m.rows) in unknown function, file ..\..\..\src\open
cv\modules\core\src\matrix.cpp, line 283

解决方案

Are you checking if the capture actually opened the file/camera ?

    if(_video.isOpened()) {  // check if capture succeeded
      // do stuff
    }

Not all codecs are supported per default. This depends on the library you use underneath to open the video. (This might be ffmpeg or quicktime).

Also you can catch the exception yourself, just to be on the safe side for future problems

try {
    _video >> frame;
} catch (cv::Exception) {
    cout << "An exception has accurred" << endl;
};

这篇关于OpenCV2.4.2 VideoAccess的未处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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