有一个 AVI 视频文件和一个网络摄像头。cvQueryFrame
在这两种情况下都返回 null。应用代码(仅适用于凸轮):
#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" );
}