摄像头捕捉程序 VC

来源:互联网 发布:我知这个世界本如露水 编辑:程序博客网 时间:2024/05/01 06:49

VC 2008 Express下安装OpenCV2.0 【图文并茂手把手教程】
http://www.opencv.org.cn/index.php/VC_2008_Express下安装OpenCV2.0


#include "stdafx.h"

#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>

int main(int argc, _TCHAR* argv[])
{
CvCapture* capture1 = cvCreateCameraCapture( 0 );


double w = 320, h = 240;
cvSetCaptureProperty ( capture1, CV_CAP_PROP_FRAME_WIDTH, w );
cvSetCaptureProperty ( capture1, CV_CAP_PROP_FRAME_HEIGHT, h );

cvNamedWindow( "Camera_1", CV_WINDOW_AUTOSIZE );

IplImage* frame1;

int n = 2;
while(1)
{
frame1 = cvQueryFrame( capture1 );
if( !frame1 ) break;
cvShowImage( "Camera_1", frame1 );

int key = cvWaitKey(30);
if( key == 27 ) break;
}
cvReleaseCapture( &capture1 );
cvDestroyWindow( "Camera_1" );

return 0;
}

 

原创粉丝点击