操作系统:windows xp
开发工具:VS2008
opencv版本:2.1.0
依赖库:OpenCV2.1\lib\highgui.lib
1 #include "cv.h" 2 #include "highgui.h" 3 4 int main() 5 { 6 cvNamedWindow("VideoTest",CV_WINDOW_AUTOSIZE); 7 CvCapture* mCapture=NULL; 8 IplImage* frame; 9 while(1) 10 { 11 mCapture=cvCreateFileCapture(-1); 12 frame=cvQueryFrame(mCapture); 13 if (!frame) 14 { 15 break; 16 } 17 cvShowImage("VideoTest",frame); 18 char c=cvWaitKey(33); 19 if (c==27) 20 { 21 break; 22 } 23 } 24 cvReleaseCapture(&mCapture); 25 cvDestroyWindow("VideoTest"); 26 }
插上你的摄像头,就可以显示了,那么短的代码,只能感叹opencv封装得很好!
时间: 2024-10-11 10:22:21