VS2010+Opencv2.4.6
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
int main(int argc, char* argv[])
{
cvNamedWindow("avi");
// CvCapture * capture=cvCreateFileCapture("E:\\Media\\1.avi");
CvCapture * capture=cvCreateCameraCapture(-1);
if(capture==NULL)
{
printf("加载文件失败!\n");
return 0;
}
IplImage* frame=NULL;
while(1)
{
frame=cvQueryFrame(capture);
if(!frame)
{
break;
}
cvShowImage("avi",frame);
char c=cvWaitKey(33);
if(c==27)
{
break;
}
}
cvReleaseCapture(&capture);
cvDestroyWindow("avi");
return 0;
}