简体   繁体   English

使用OpenCV检索视频帧-未处理的异常

[英]Retrieving video frames using opencv - unhandled exception

I am getting video frames using cvQueryframes , but in few videos of avi file I get : 我正在使用cvQueryframes获取视频帧,但是在avi文件的一些视频中,我得到了:

Unhandled exception at 0x715c14f0 0xC0000005: 
    Access violation reading location 0x02f509f0.

I am using visual studio 2010 with OpenCV 2.4.5 and Qt5 我正在将Visual Studio 2010与OpenCV 2.4.5Qt5

CvCapture* cap= cvCaptureFromFile(file);
frame = cvQueryFrame(capture);

There could be multiple reasons for this, link wrong file name, codec not found etc. Try putting debug printf before opening file to see if file name is proper also check for cap if it is not NULL. 可能有多种原因,链接错误的文件名,未找到编解码器等。尝试在打开文件前放入debug printf,以查看文件名是否正确,如果不是NULL,请检查cap的大小。 You can try something like this 您可以尝试这样的事情

int main(int argc, char*argv[])
{

    char *my_file = "C:\\vid_an2\\desp_me.avi";
    std::cout<<"Video File "<<my_file<<std::endl;
    cv::VideoCapture input_video;

    if(input_video.open(my_file))
    {
         std::cout<<"Video file open "<<std::endl;
    }
    else
    {
        std::cout<<"Not able to Video file open "<<std::endl;

    }
    namedWindow("My_Win",1);
    namedWindow("Segemented", 1);
    Mat cap_img;
    for(;;)
    {
         input_video >> cap_img;
         imshow("My_Win", cap_img);
          waitKey(0);
    }
   return 0;
 }

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

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