#pragma warning(disable : 4996)
#pragma comment( lib, "cxcore.lib" )
#pragma comment( lib, "highgui.lib" )
#include <cxcore.h>
#include <highgui.h>
void main(int argc, char *argv[])
{
CvCapture* capture = 0;//视频流捕获
if(argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
capture = cvCaptureFromCAM(argc == 2 ? argv[1][0] - '0' : 0);//从摄像头获得视频流
else if( argc == 2 )
capture = cvCaptureFromAVI(argv[1]);//从文件获得视频流
if(!capture)
return;
IplImage *current_frame_rgb = cvCreateImage(cvSize(320, 240), IPL_DEPTH_16U, 3);
cvNamedWindow("Window 0", 0);
while(capture)
{
current_frame_rgb = cvQueryFrame(capture);//获得一帧图象
cvShowImage("Window 0",current_frame_rgb);
if(cvWaitKey(1)==27)//等待ESC键
break;
}
cvDestroyAllWindows();
}
#pragma comment( lib, "cxcore.lib" )
#pragma comment( lib, "highgui.lib" )
#include <cxcore.h>
#include <highgui.h>
void main(int argc, char *argv[])
{
CvCapture* capture = 0;//视频流捕获
if(argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
capture = cvCaptureFromCAM(argc == 2 ? argv[1][0] - '0' : 0);//从摄像头获得视频流
else if( argc == 2 )
capture = cvCaptureFromAVI(argv[1]);//从文件获得视频流
if(!capture)
return;
IplImage *current_frame_rgb = cvCreateImage(cvSize(320, 240), IPL_DEPTH_16U, 3);
cvNamedWindow("Window 0", 0);
while(capture)
{
current_frame_rgb = cvQueryFrame(capture);//获得一帧图象
cvShowImage("Window 0",current_frame_rgb);
if(cvWaitKey(1)==27)//等待ESC键
break;
}
cvDestroyAllWindows();
}