1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include "unistd.h"
// A Simple Camera Capture Framework
int main() {
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
if ( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
printf("starting:\n");
// Get one frame
IplImage* frame = cvQueryFrame( capture );
if ( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
}
else cvSaveImage("./camera.jpg", frame,0)
// Release the capture device housekeeping
cvReleaseCapture( &capture );
//sleep(3);
//fflush(0);
//another picture
CvCapture* capture2 = cvCaptureFromCAM( CV_CAP_ANY );
if ( !capture2 ) {
fprintf( stderr, "ERROR: capture2 is NULL \n" );
getchar();
return -1;
}
printf("starting:\n");
// Get one frame
IplImage* frame2 = cvQueryFrame( capture2 );
if ( !frame2 ) {
fprintf( stderr, "ERROR: frame2 is null...\n" );
}
else cvSaveImage("./camera2.jpg", frame2,0);
// Release the capture device housekeeping
cvReleaseCapture( &capture2 );
return 0;
} |
Partager