【发布时间】:2013-06-21 19:00:04
【问题描述】:
我正在尝试从文件中打开视频 (.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。
谁能帮我理解这些代码有什么问题以及如何修复它们?谢谢!!
【问题讨论】:
-
您在哪个平台上运行代码? Windows 还是 Linux?还有你用的opencv版本是什么?
标签: c++ c opencv video-streaming video-processing