How to make a webcam page with Apache on Linux (obsolete): Difference between revisions

From www.ReeltoReel.nl Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
How to make a webcam page with Apache on Linux
How to make a page on your webserver displaying a picture of your webcam using Linux and Apache
How to make a page on your webserver displaying a picture of your webcam using Linux and Apache



Revision as of 18:03, 14 January 2008

How to make a page on your webserver displaying a picture of your webcam using Linux and Apache

This document describes, in short, how to make a page on your webserver to display a semi-continuous image of your webcam. This document is in fact, the documentation of such an installation on my machine running SuSE Linux Professional 9.2. [update: this should however work on newer version also]

The webcam involved is a Philips ToUCam Pro. In this example, it is connected to the webserver. But it is possible to have the image uploaded from another computer as well.

This solution uses a 2 stage approach, which makes it modular. The first stage/module captures images from the device using the commandline tool webcam and places the image in a directory, and the second stage/module is the HTML-page that publishes this image on a regular interval using a java applet (or you can go for a more simple solution and use a static page).

1st step: Check webcam.

First of all, you need to have a working webcam on your computer. You can verify this by using your webcam with an application such as KDETV, XAWTV or just use GnomeMeeting. If you haven't installed these packages, do so now. It will make troubleshooting easier. Check if you have a good quality picture.In my case, the driver for the ToUCam wasn't included in the kernel anymore, so I had to use the new driver from http://www.saillard.org/linux/pwc/ which was actually quite easy to install. You need to have your kernel sources ready, however. I hope that your webcam works out of the box, that is a lot easier.Once this works, and only then, you can go to the next step.

2nd step: Capture images.

Ok, now you have a working webcam, and it's time to capture images from it. We will use a command-line tool called 'webcam'. This is a simple binary available in most distributions. It requires a simple configuration file. Start a shell and type 'webcam'. You should get a message saying something about 'reading config file'. We'll get to that later. If you get 'command not found', that means you should install this tool from your distro CD/DVD. Once installed, you can now do a 'man webcam' to see all the info about this utility. But we will need to make a configuration file first. In this example we will put the configuration file in /etc and name it 'webcam.conf'. A sample configuration file 'webcam.conf' would look like this:


[grab]
device = /dev/video0
text = "webcam %Y-%m-%d %H:%M:%S"
infofile = filename
fg_red = 255
fg_green = 255
fg_blue = 255
width = 320
height = 240
delay = 3
wait = 0
input = composite1
norm = pal
rotate = 0
top = 0
left = 0
bottom = -1
right = -1
quality = 75
trigger = 0
once = 0

[ftp]
host = www
user = webcam
pass = xxxxxx
dir = public_html/images
file = webcam.jpeg
tmp = uploading.jpeg
passive = 1
debug = 0
auto = 0
local = 0
ssh = 0
 

As you see, it has 2 main sections. In the [grab] section, you may want to change the line: device= to match your configuration. Comment out the line infofile. Adjust the lines width and height to your needs. Delay is the time in seconds between captures, and quality is the jpeg quality, from 0 to 100.

In the [ftp] section, if you use a locally connected webcam, use the line local =1, and fill in the lines dir and file and you're done! If you have a webcam connected to an other workstation in your LAN, you will have to run webcam on that computer and adjust the lines host, user and pass to match the FTP settings of your web-host.

When this is done, you can start the program by typing

$webcam [path-to-configfile]

so the command would be

$webcam /etc/webcam.conf

Type this in your command shell.