码迷,mamicode.com
首页 > 其他好文 > 详细

实验2014051901:opencv操作摄像头

时间:2014-05-20 11:12:01      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   class   c   code   

实验1

  实验目的:使用opencv操作摄像头拍摄一张图片

  函数:

   

1 CvCapture* cvCreateCameraCapture( int index ); 
2 IplImage* cvQueryFrame( CvCapture* capture ); 

  实验代码:

    

bubuko.com,布布扣
 1 #include"highgui.h"
 2 #include"cv.h"
 3 int main(){
 4     cvNamedWindow("w",0);
 5     IplImage* img;
 6     CvCapture* pCapture =cvCreateCameraCapture(0);
 7 
 8     cvWaitKey();
 9     img=cvQueryFrame( pCapture );
10     cvShowImage("w",img);
11     cvWaitKey();
12     
13     cvReleaseCapture(&pCapture);
14     cvDestroyWindow("w");
15     return 0;
16 }
bubuko.com,布布扣

 实验2

  实验目的:使用opencv操作摄像头拍摄视频

  实验代码:

bubuko.com,布布扣
 1 #include"highgui.h"
 2 #include"cv.h"
 3 int main(){
 4     cvNamedWindow("w",0);
 5     IplImage* img;
 6     CvCapture* pCapture =cvCreateCameraCapture(0);
 7 
 8     cvWaitKey();
 9 
10     while(1){
11         img=cvQueryFrame( pCapture );
12         cvShowImage("w",img);
13         char temp=cvWaitKey(40);
14         if(temp==27)break;
15     }
16     
17     cvReleaseCapture(&pCapture);
18     cvDestroyWindow("w");
19     return 0;
20 }
bubuko.com,布布扣

 

实验2014051901:opencv操作摄像头,布布扣,bubuko.com

实验2014051901:opencv操作摄像头

标签:des   style   blog   class   c   code   

原文地址:http://www.cnblogs.com/experiments-of-ORLAN/p/3737452.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!