Webcam Server.

Dependencies:   uvchost FatFileSystem mbed HTTPServer NetServicesMin

Revision:
0:2b4ea8a138e5
Child:
1:7a4f2c038803
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebcamServer.cpp	Wed Jun 06 11:47:06 2012 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+#include "uvc.h"
+#include "EthernetNetIf.h"
+//#include "WIZ820ioNetIf.h"
+#include "HTTPServer.h"
+#include "WebcamHandler.h"
+#include "WebcamInput.h"
+Serial pc(USBTX, USBRX);
+
+HTTPServer svr;
+
+EthernetNetIf eth;
+//WIZ820ioNetIf eth;
+
+#define CAM_COUNT 2
+
+uvc* Webcam[CAM_COUNT];
+
+int main() {
+    pc.baud(921600);
+
+    for(int i = 0; i < CAM_COUNT; i++) {
+        uvc* cam = new uvc(i);
+        cam->SetImageSize(160, 120);
+        WebcamInput* input = new WebcamInput(i);
+        cam->attach(input);
+        if (cam->setup() < 0) exit(1);
+        Webcam[i] = cam;
+    }
+
+    int ethErr = eth.setup();
+    if (ethErr < 0) exit(1);
+    IpAddr ip = eth.getIp();
+    printf("http://%d.%d.%d.%d/\n", ip[0], ip[1], ip[2], ip[3]);
+    svr.addHandler<WebcamHandler>("/");
+    svr.bind(80);
+
+    while(1) {
+        Net::poll();
+        for(int i = 0; i < CAM_COUNT; i++) {
+            Webcam[i]->poll();
+        }
+    }
+}