+
+ CvMat * g_src = NULL; // Source Image
+ CvMat * g_encoded; // Encoded Image
+
+ Camera_GetImage( num, width, height ,g_src);
+ g_encoded = cvEncodeImage("test_encode.jpg",g_src,0);
+
+ Log(LOGNOTE, "Sending image!");
+ FCGI_PrintRaw("Content-type: image/jpg\r\n");
+ FCGI_PrintRaw("Cache-Control: no-cache, no-store, must-revalidate\r\n\r\n");
+ //FCGI_PrintRaw("Content-Length: %d", g_encoded->rows*g_encoded->cols);
+ FCGI_WriteBinary(g_encoded->data.ptr,1,g_encoded->rows*g_encoded->cols);
+
+ cvReleaseMat(&g_encoded);
+ cvReleaseMat(&g_src);
+}
+
+ bool Camera_GetImage(int num, int width, int height, CvMat * image)
+ {
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; // Need to use a mutex to ensure 2 captures are not open at once
+ pthread_mutex_lock(&mutex);
+ bool result = false;