【问题标题】:show a video from a file in opencv在opencv中显示文件中的视频
【发布时间】: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


【解决方案1】:

我认为这是一个类似的问题Unhandled exception at 0x10012c5d (highgui110.dll)。主要的一点是您可能正在使用可能存在链接问题的不稳定版本的 OpenCV。尝试恢复到以前版本的 OpenCV,看看它是否有效。希望对您有所帮助!

【讨论】:

    猜你喜欢
    • 2012-07-30
    • 1970-01-01
    • 1970-01-01
    • 2012-04-13
    • 2023-02-16
    • 2017-05-29
    • 1970-01-01
    • 2017-11-21
    • 1970-01-01
    相关资源
    最近更新 更多