7 void Image_Handler(FCGIContext * context, char * params)
9 static CvCapture * capture = NULL;
10 if (capture == NULL) {
11 capture = cvCreateCameraCapture(0);
12 //limit resolution to work on bbb
13 cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 352);
14 cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 288);
16 static int p[] = {CV_IMWRITE_JPEG_QUALITY, 100, 0};
18 IplImage * frame = cvQueryFrame(capture);
19 assert(frame != NULL);
22 // CvMat * background = cvGetMat(frame, &stub, 0, 0);
24 // CvMat *cv8u = cvCreateMat(frame->width, frame->height, CV_8U);
27 // cvMinMaxLoc(background, &min, &max, &a, &b, 0);
29 // double ccscale = 255.0/(max-min);
30 // double ccshift = -min;
31 //cvCvtScale(frame, cv8u, ccscale, ccshift);
32 CvMat * jpg = cvEncodeImage(".jpg", frame, p);
35 Log(LOGNOTE, "Sending image!");
36 FCGI_PrintRaw("Content-type: image/jpg\r\n");
37 FCGI_PrintRaw("Cache-Control: no-cache, no-store, must-revalidate\r\n\r\n");
38 //FCGI_PrintRaw("Content-Length: %d", jpg->rows*jpg->cols);
39 FCGI_WriteBinary(jpg->data.ptr,1,jpg->rows*jpg->cols);
42 cvReleaseImageHeader(&frame);