News:

Registered a URL and setup a forum as the IPCam stuff really needed its own site vs my irregular blog posts about IPCam hacking at http://www.computersolutions.cn/blog

Author Topic: ipcamd: an embedded IP camera web server  (Read 5286 times)

June 30, 2013, 09:57:27 am
Hi,

this is an IP camera daemon that reads video frames from the camera and publishes them to connected HTTP clients. You can find the source code at https://github.com/rhuitl/uClinux/blob/ipcamd/user/ipcamd/.

For the HTTP server part, libmicrohttpd is used.
A simple motion detection algorithm is implemented and runs fast enough to keep up with the frame rate. It works by decoding a sub-sampled version of the image (80x60 for 640x480 JPEG frames) and creating a moving average background image. Image frames can then be compared against the background to detection motion. Right now no action is performed when motion is detected, but depending on the application one could trigger an alarm or suspend the HTTP transmission (sending only keep-alives) until motion is detected.

A very experimental feature is SSL signing of a video frame's hash value. This way one could make sure no one is tampering with the video frames as they are transmitted wirelessly. AFAIR the signing takes a few hundred miliseconds, so that might be a bit too slow.

Please check the commit log to find out how to setup your uClinux tree to build ipcamd. You'll also have to add libmicrohttpd to the lib/ directory (see https://github.com/rhuitl/uClinux/commits/master/lib/libmicrohttpd).

Command line options:
Code: [Select]
Options:
-d | --device name   Video device name [/dev/video]
-h | --help          Print this message
-m | --mmap          Use memory mapped buffers
-r | --read          Use read() calls
-u | --userp         Use application allocated buffers
-p | --private       Use private mapping (use with -m)
-c | --count         Number of frames to grab
-w | --width         Set width (640 or 320), height is auto-selected
-j | --decode-jpeg   Decode DC coefficients of JPEG, repeat to save as /tmp/test.pgm
-s | --sign-jpeg     Sign SHA1 hash of JPEG data
-D | --dhcp          Start dhcpcd to handle network setup
-v | --verbose       Be verbose, e.g., print video frames

If it works with your webcam driver, you should use mmap() (-m instead of -r or -u) in order to minimize copying of image data.