OpenCV2.4.2 Unhandled Exception in VideoCapture

I just installed OpenCV2.4.2 and created an OpenCV project using CMake. I have no compilation errors. I have several functions for image processing, and I have 2 applications:

1- processes data from video

2- processes the simulated data.

Both applications are identical, except for extracting data from the video.

PROBLEM : application processing video crashes with

Unhandled exception at 0x75d8a048 in program.exe Access violation Access point read 0x049f08c0.

Crash 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 think that the problem with the cv::VideoCapture in OpenCV 2.4.2 may be the problem. How can I detect a problem and solve it?

EDIT

With the camcorder, 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 
+6
source share
1 answer

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 by default. It depends on the library you use to open the video. (It could be ffmpeg or quicktime).

You can also catch the exception yourself, just to be safe for future problems.

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

Source: https://habr.com/ru/post/925025/


All Articles