Why OpenCV's `cvCreateCameraCapture` and `cvCreateFileCapture` do not work?


Question

Have an AVI videofile, and a webcam. cvQueryFrame returns null in both cases. Code is applied(only for cam):

#include "highgui.h"
#include <iostream>

using namespace std;

int main( int argc, char** argv )
{   
    cvNamedWindow( "KillCam", CV_WINDOW_AUTOSIZE );
    cvWaitKey(0);
    CvCapture* capture = cvCreateCameraCapture(-1);
    assert(capture != NULL);
    IplImage* frame;

    while(1){
        frame = cvQueryFrame( capture ); 
        if( !frame ) break;
        cvShowImage( "KillCam", frame );
        char c = cvWaitKey(33);
        if( c == 30 ) break;
    }
    cvReleaseCapture( &capture );
    cvDestroyWindow( "KillCam" );
}
1
1
12/16/2017 11:23:18 AM

I found, by stepping into the openCV code, that I needed to ensure the fmpeg dll was present in the current working directory at runtime:

opencv_ffmpeg200d.dll

OpenCV doesn't shed any warning if this dll is not found, instead the capture create call just returns NULL.

hth

Si

3
2/11/2010 11:42:43 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon