Add "image" module
[matches/MCTX3420.git] / server / image.c
diff --git a/server/image.c b/server/image.c
new file mode 100644 (file)
index 0000000..81c692b
--- /dev/null
@@ -0,0 +1,25 @@
+#include "cv.h"
+#include "highgui_c.h"
+#include "image.h"
+#include <string.h>
+#include <stdio.h>
+
+void Image_Handler(FCGIContext * context, const char * params)
+{
+       static CvCapture * capture = NULL;
+       if (capture == NULL)
+               capture = cvCreateCameraCapture(-1);
+       
+       static int p[] = {CV_IMWRITE_JPEG_QUALITY, 100, 0};
+
+       IplImage * frame = cvQueryFrame(capture);
+       assert(frame != NULL);
+       CvMat * jpg = cvEncodeImage(".jpg", frame, p);
+
+       // Will this work?
+       Log(LOGNOTE, "Sending image!");
+       FCGI_PrintRaw("Content-type: image/jpg\r\n\r\n");
+       //FCGI_PrintRaw("Content-Length: %d", jpg->rows*jpg->cols);
+       FCGI_WriteBinary(jpg->data.ptr,1,jpg->rows*jpg->cols);
+       
+}

UCC git Repository :: git.ucc.asn.au