Marko Mäkelä’s software projects: A Linux-based Web Camera Server on a Floppy Disk

What?

This is a boot floppy for an inexpensive PC equipped with a Firewire desktop camera and an Ethernet adapter, for capturing and sending images to a web server.

This may have been a feasible solution in 2004, before inexpensive systems based on ARM SoCs such as the Raspberry Pi became mainstream.

This is not meant to be a security solution; there is no motion detection, and images are typically captured something like once per minute.

Nowadays you could simply install a full GNU/Linux distribution on a MicroSD card. The file system image size would be measured in gigabytes, not in megabytes, and you would be able to use all standard tools and libraries. Instead of writing a statically linked C program, you could even write a script that makes use of prebuilt programs from the distribution. Then again, building a bare-bones system might have the benefit of containing fewer security holes.

Why?

I wanted to see if I can build a cheap Internet enabled camera system that can be connected to a dynamic NAT firewall or otherwise crippled Internet connection that disallows inbound connections.

I acquired the following components:

Component Price
ADS Pyro Webcam API-203 70 €
An OHCI compliant PCI to IEEE-1394 adapter 17 €
An old PC with PCI bus and an Ethernet adapter 30 €

Virtually any old PC should be suitable, provided that it is equipped with a PCI bus for the Firewire adapter. No hard disk or CD-ROM drive is needed.

How?

Please refer to the build instructions. Download the listed source packages, compile them using the provided configuration, and create a boot floppy as described.

Download the sender/receiver software and compile and install receiver.c on the web server. You may want to adapt receiver.sh and use it as a front-end. Compile the sender software and install it to the boot floppy, with the lens correction parameters in lens.h adapted for your camera.

Connect the PC to an Ethernet router, and plug in the web camera. The PC will start serving images to the web server. The receiver program running on the server will control how often and at which resolution the images are captured.

Features

Discussion

Firewire Cameras Tend to Be Expensive

The main reason why this might not be economically viable in large scale is that there are very few reasonably priced Firewire cameras. IIDC compliant cameras tend to be designed for industrial use and an order of magnitude too expensive for web camera applications.

Driver Trouble with USB Cameras

There is healthy competition in the domain of USB based web cameras. Unfortunately, with the exception of the fairly recently introduced USB Video Class there is no standard interface for USB based cameras, and manufacturers do not provide free software drivers; only closed-source drivers for proprietary operating systems.

Reverse engineering the protocols is difficult, and it is not very rewarding, since new camera models will have different hardware and different protocols. The protocols are not straightforward, because all USB 1.1 or USB 2.0 full speed (12 Mb/s) compliant cameras need to compress the image data somehow. Cameras using USB 2.0 high speed transfer (480 Mb/s) should not require any compression, but even those cameras are not well supported in Linux yet.

Using the manufacturer-supplied Windows drivers is not an option, because Windows has much higher hardware requirements than our customised version of Linux, and thus we would be unable to use a cheap old PC. Also, in order to use Windows, an expensive license would have to be paid for.

CCTV Cameras Connected to a Video Card

There exists an excellent Video for Linux driver for Brooktree Bt848 and Bt878 based video capturing cards. There are relatively inexpensive weather-proof analog video cameras. It could be possible to implement something similar using that kind of hardware.

Software Implementation

Image capturing

Images are captured via the libdc1394 library. The file capture-dc.c was written based on the information obtained from the source code of Coriander. The author of Coriander, Damien Douxchamps, also maintains a list of IEEE-1394 digital uncompressed-video cameras.

Lens Correction

The ADS Pyro Webcam API-203 is equipped with a lens that produces notable barrel distortion. This type of distortion can be corrected easily by transforming each point in the image, changing its distance r from the center of the image to a·(r+b·r²+c·r⁴), preserving the direction. The coefficient a provides just scaling, while b is the main correction factor, and c affects the correction mainly near the edges of the image.

The implementation of lens correction is based on the algorithm of David Hodson’s GIMP Wideangle plugin. Our implementation is also used for scaling the image. The source image is sampled with Catmull-Rom cubic interpolation.

Download

Build instructions
capture.tar.gz
Source code for two programs:
sender
captures images via libdc1394, corrects lens distortion, compresses and encodes them to JPEG JFIF and transmits them to a child process via a pipe.
receiver
receives images from a pipe and writes them to files following a user-definable pattern

Status

I do not plan to maintain this document or the software. Feel free to do anything with this, as long as you follow the terms of the GNU General Public License, version 2 or later.

Contact me if you would like to have paid consulting services.