6 /*-------------------------------------------------------------------
9 -I/usr/include/opencv -I/usr/include/opencv2/highgui -L/usr/lib -lopencv_highgui -lopencv_core -lopencv_ml -lopencv_imgproc
11 --------------------------------------------------------------------*/
13 int storeFrame( CvCapture* capture)
18 //FILE *fp = fopen ("test.jpg", "wb");
21 p[0] = CV_IMWRITE_JPEG_QUALITY;
22 p[1] = 100; //quality value. 0-100
25 frame = cvQueryFrame(capture);
28 cvSaveImage("../web/images/test.JPG",frame,p);
29 //jpg = cvEncodeImage(".jpg", frame,p);
30 /*pass buf to client, write to file on client*/
31 //fwrite(jpg->data.ptr,1,jpg->rows*jpg->cols, fp);
33 //decjpg = cvDecodeImage(jpg, CV_LOAD_IMAGE_COLOR);
34 //cvShowImage( "Display window", decjpg );
37 cvReleaseImageHeader(&frame);
43 int main (int argc, char** argv)
46 //cvNamedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
47 //Get capture structure for camera, -1 refers to any camera device.
48 //If multiple cameras used, need to use specific camera ID
49 capture = cvCreateCameraCapture(-1);
50 //If cvCreateCameraCapture returns NULL there is an error with the camera
54 cvSetCaptureProperty (capture, CV_CAP_PROP_FOURCC, 'MJPEG');
58 if( !storeFrame( capture))
60 printf("enter to continue");
62 //sleep(1); //for now just to make the camera take 1 shot a second, as that's all my camera seems to be able to take/save (camera or function causing this? is 1 second per frame enough?)
65 //Need to determine how the function is called in respect to system. just leave it running with a while loop? will something turn it on and off? will the function be called once from elsewhere?
66 cvReleaseCapture( &capture);