标签:
#include <cv.h> #include <highgui.h> #if 0 //測试opencv环境数据 int main() { const char* filename = "g:\\test.jpg" ;//换成你自己的文件路径名!!请注意,双斜杠!!const char* wndname = "http://blog.csdn.net/moc062066" ; IplImage* pImage = cvLoadImage(filename,CV_LOAD_IMAGE_COLOR) ; cvNamedWindow(wndname,CV_WINDOW_AUTOSIZE); cvShowImage(wndname,pImage); cvWaitKey(0); cvReleaseImage(&pImage); cvDestroyWindow(wndname); return 0; } #else //採集摄像头数据 #include <cv.h> #include <cxcore.h> #include <highgui.h> int main( int argc, char** argv ) { //声明IplImage指针 IplImage* pFrame = NULL; //获取摄像头 CvCapture* pCapture = cvCreateCameraCapture(-1); //创建窗体 cvNamedWindow("video", 1); cvResizeWindow("video",300,300); //显示视屏 while(1) { pFrame=cvQueryFrame( pCapture ); if(!pFrame)break; cvShowImage("video",pFrame); char c=cvWaitKey(33); if(c==27)break; } cvReleaseCapture(&pCapture); cvDestroyWindow("video"); } #endif
版权声明:本文博主原创文章,博客,未经同意不得转载。
标签:
原文地址:http://www.cnblogs.com/yxwkf/p/4857397.html