我正在尝试从文件中打开视频(.avi),逐帧读取并将其显示在窗口中。我在堆栈溢出中查看了一下,发现了一些有趣的代码,但是每个代码都使我的程序崩溃,我也不知道为什么。我使用以下代码:
int main( int argc, const char** argv ) {
CvCapture* capture = 0;
string inputName = "C:\\Users\\Cristina\\Videos\\Capture_me.avi";
capture = cvCaptureFromAVI( inputName.c_str() );
if( !capture ) {
cout << "Capture from AVI didn't work" << endl;
} else {
cvNamedWindow( "result", CV_WINDOW_AUTOSIZE );
cout << "In capture ..." << endl;
IplImage* currFrame = cvQueryFrame( capture );
IplImage* prevFrame = cvCloneImage( currFrame );
while( currFrame = cvQueryFrame( capture ) ) {
if( !currFrame )
break;
cvShowImage( "result", currFrame );
cvCopy( currFrame , prevFrame );
}
waitKey(0);
cvReleaseCapture( &capture );
cvReleaseImage( &currFrame );
cvDestroyWindow( "result" );
}
return 0;
}
while循环条件抛出:FaceDetection.exe中0x0000000066E538C6(opencv_ffmpeg245_64.dll)的未处理异常:0xC0000005:访问冲突读取位置0x0000000002EF1000。
我也尝试了相同的程序,但是有这个循环:
while( cvGrabFrame( capture ) ) {
if( !currFrame )
break;
cvShowImage( "result", currFrame );
cvCopy( currFrame, prevFrame );
currFrame = cvRetrieveFrame( capture );
}
第二个while循环条件在“ currFrame = cvRetrieveFrame(capture);”处引发相同的异常。 :FaceDetection.exe中0x0000000066E538C6(opencv_ffmpeg245_64.dll)处未处理的异常:0xC0000005:访问冲突读取位置0x0000000003011000。
有人可以帮我了解这些代码有什么问题,以及如何解决这些问题吗?谢谢!!
最佳答案
我认为这是一个类似的问题Unhandled exception at 0x10012c5d (highgui110.dll)。重点是您可能使用的是不稳定版本的OpenCV,该版本可能存在链接问题。尝试恢复到以前的OpenCV版本,看看它是否有效。希望能帮助到你!