Advertisement
Guest User

sampleopencv

a guest
Jan 5th, 2012
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. // #include <cv.h>
  2. #include <highgui.h>
  3. #include <stdio.h>  
  4.  
  5. int main() {
  6.   CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
  7.   if ( !capture ) {
  8.     fprintf( stderr, "ERROR: capture is NULL \n" );
  9.     getchar();
  10.     return -1;
  11.   }
  12.   while ( 1 ) {
  13.     IplImage* frame = cvQueryFrame( capture );
  14.     if ( !frame ) {
  15.       fprintf( stderr, "ERROR: frame is null...\n" );
  16.       getchar();
  17.       break;
  18.     }
  19.     cvSaveImage( "image.jpg", frame, 0);
  20.     if ( (cvWaitKey(10) & 255) == 27 ) break;
  21.   }
  22.   cvReleaseCapture( &capture );
  23.   return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement