Play AVI files in OpenCV

I cannot play avi files using OpenCV. I am on a Mac and the files work with Quicktime and a VLC player. I tried using mencoder to convert it to i420, but this still failed. Error messages do not appear, and it seems that the program automatically closes, and I'm not sure how to debug it.

int main(int argc, char* argv[]) 
{
    cvNamedWindow( "Example2", CV_WINDOW_AUTOSIZE );
    CvCapture* capture = cvCreateFileCapture( argv[1] );
    IplImage* frame;
    while(1) {
        frame = cvQueryFrame( capture );
        if( !frame ) break;
        cvShowImage( "Example2", frame );
        char c = cvWaitKey(33);
        if( c == 27 ) break;
    }
    cvReleaseCapture( &capture );
    cvDestroyWindow( "Example2" );
}
+3
source share
1 answer

Well, since there is no error checking in your code, there may be a problem with cvCreateFileCapture (), and you will never know until you check the return function.

In any case, you must either remove or add debugging for this statement here:

if( !frame ) break;

, , " ".

- :

if (!frame) { printf("Uow, huge fail!\n"); break;}

: cvCaptureFromAVI()? : http://nashruddin.com/How_to_Play_AVI_Files_with_OpenCV

0

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


All Articles