简体   繁体   English

VideoCapture上的OpenCV2.4.2未处理异常

[英]OpenCV2.4.2 unhandled exception on VideoCapture

I just installed OpenCV2.4.2 and created an OpenCV project using CMake. 我刚刚安装了OpenCV2.4.2并使用CMake创建了一个OpenCV项目。 I don't get any compilation errors. 我没有得到任何编译错误。 I have several functions for processing images and I have 2 applications: 我有几个处理图像的功能,我有2个应用程序:

1- Processes data from a video 1-处理视频中的数据

2- Processes simulated data. 2-处理模拟数据。

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. program.exe访问冲突读取位置0x049f08c0中0x75d8a048处的未处理异常。

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. 所以我猜在OpenCV 2.4.2中可能存在cv::VideoCapture类的问题。 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). (这可能是ffmpeg或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;
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM