X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fimage.c;h=0e4ff48603e1d2ee740cdd0d7fe77630f18b4391;hb=a671f27ecb900f91bf32b8b13edb678009e319c1;hp=a32ac2cdcb7996bc1f072cb536312ff95a9812da;hpb=1788aa399989e919221f0bf4c8b6114bef4a49a9;p=matches%2FMCTX3420.git diff --git a/server/image.c b/server/image.c index a32ac2c..0e4ff48 100644 --- a/server/image.c +++ b/server/image.c @@ -8,8 +8,14 @@ static CvCapture * g_capture = NULL; static int g_captureID = -1; +/** + * Image stream handler. Returns an image to the user. + * @param context The context to work in + * @param params User specified parameters + */ void Image_Handler(FCGIContext * context, char * params) { + int num = 0, width = 1600, height = 1200; // Set Default values FCGIValue val[] = { {"num", &num, FCGI_INT_T}, @@ -52,7 +58,7 @@ void Image_Handler(FCGIContext * context, char * params) * @param num - Camera id * @param width - Width to force * @param height - Height to force - * @param image - Pointer to CvMat* to set with result + * @param frame - Pointer to IplImage* to set with result * @returns true on success, false on error */ bool Camera_GetImage(int num, int width, int height, IplImage ** frame) @@ -74,24 +80,31 @@ void Image_Handler(FCGIContext * context, char * params) g_captureID = num; } - cvSetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_WIDTH, width); - cvSetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_HEIGHT, height); + if (g_capture != NULL) + { + + cvSetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_WIDTH, width); + cvSetCaptureProperty(g_capture, CV_CAP_PROP_FRAME_HEIGHT, height); - *frame = cvQueryFrame(g_capture); - result = (*frame != NULL); + *frame = cvQueryFrame(g_capture); + result = (*frame != NULL); //cvShowImage("display", *image); //cvWaitKey(0); //cvSaveImage("test.jpg",*image,0); - Log(LOGDEBUG, "At end of mutex"); - + Log(LOGDEBUG, "At end of mutex"); + } + pthread_mutex_unlock(&mutex); //Close the mutex //NOTE: Never have a "return" statement before the mutex is unlocked; it causes deadlocks! return result; } +/** + * Executed on cleanup. Releases the OpenCV Capture structs. + */ void Image_Cleanup() { // Release the capture and IplImage pointers