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

You have an AVI video file and a webcam. cvQueryFrame returns null in both cases. Code applies (for camera only):

 #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
c ++ opencv video video-capture webcam
Jan 01 '09 at 3:20
source share
2 answers

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

 opencv_ffmpeg200d.dll 

OpenCV does not shed any warnings if this DLL is not found; instead, a call to create a capture returns NULL.

hth

Si

+3
Feb 11 2018-10-11
source share

Check the video format. OpenCV can be legible in which codecs it supports; for example, it does not work with Xvid. You can find the list of supported codecs in the OpenCV wiki

0
Jan 10
source share



All Articles