Advertisement
Guest User

OpenCV 2.1 Camera Test

a guest
Jul 11th, 2010
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. /*
  2.     Compile with opencv 2.1 April 2010 Release
  3.  
  4.     Assuming you have the libraries installed centrally, e.g. prefix /usr thus /usr/include and /usr/lib
  5.     you can compile with:
  6.  
  7.     gcc -g -std=c99 -lopencv_highgui -lopencv_core -lopencv_imgproc -lopencv_features2d main.c -o CamTest
  8.  
  9.     I recommend -g so you can use gdb with something like gdb ./CamTest and then inside gdb:
  10.  
  11.     b 7
  12.     run
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include <opencv/cv.h>
  17. #include <opencv/highgui.h>
  18.  
  19. int main(int argc, char **argv)
  20. {
  21.     IplImage *l_ipiCapture;
  22.     CvCapture *l_cvcCamera;
  23.  
  24.  
  25.     l_cvcCamera = cvCreateCameraCapture(CV_CAP_ANY);
  26.     if(!l_cvcCamera)
  27.     {
  28.         printf("Unable to capture camera.");
  29.         exit(1);
  30.     }
  31.    
  32.     while(1)
  33.     {
  34.         cvNamedWindow("Cam Test",CV_WINDOW_AUTOSIZE);
  35.  
  36.         l_ipiCapture = cvQueryFrame(l_cvcCamera);
  37.        
  38.         cvShowImage("Cam Test",l_ipiCapture);
  39.  
  40.         if( (cvWaitKey(10) & 255) == 27 ) break;
  41.     }
  42.  
  43.     cvReleaseImage(&l_ipiCapture);
  44.     cvReleaseCapture(&l_cvcCamera);
  45.  
  46.     cvDestroyWindow("Cam Test");
  47.  
  48.     exit(0);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement