Powered by SiliconGraphics

TU Delft ITS Webcam Setup

Camera

We are using a Silicon Graphics Indy (100Mhz IP22, 64 Mb ram, IRIX 5.2) with an IndyCam digital color video camera. The Indy comes with an IndyCam out of the box, so if your Indy does not have one, ask you system administrator. If he refuses, make him believe it is the perfect way to keep an eye on what's going on in the room!

First, make sure the IndyCam is plugged in, and slide the lens cover to the side.

Next, log in on the Indy and start videopanel. In the Device(s): VINO Device Controls box select IndyCam as default input, and make sure the settings of the IndyCam are reset to their defaults by selecting Restore Factory Settings (ctrl-f) from the File menu.

To see if the IndyCam actually works, you'll have to be logged in at the console of the Indy (ie, not remote), and start videoin. You should see live images now! If not, make sure the IndyCam is plugged in correctly, the lens cover is not over the lens and the default VINO video input device is the IndyCam. If it still does not work, make sure /dev/vid and /dev/video are at least readable to you and run hinv to see if the IndyCam is detected:

...
Vino video: unit 0, revision 0, Indycam connected
...
When you find a problem here, it is probably a good thing to call in the system administrator and let him set the permissions right and/or reboot the Indy.

Camera Settings

You'll probably want to fine tune the IndyCam settings. On the videopanel, select IndyCam Signal Controls from the Pro menu. My settings here are:
AGC:		disabled
Shutterspeed:	1/60th Sec
Gain:		.875
Red balance:	.435
Blue balance:	.439
Saturation:	.447
The actual picture you'll get is not only monitor but also program dependent. videoin can not always be trusted to display the right brightness and colors, especially since the Indy has only 8-bit (256 color) video, and the gamma value of the X server defaults to 1.7 (which gives quite a bright picture on my non-SGI 21" monitor). Also, the RGB-to-Jpeg convertors I've tried seem to darken the image a little. Be sure to check the picture on other machines with true-color video after you've adjusted the settings! If you did a remote login, just assume the Silicon Graphics people did a reasonable job on the settings for now.

Brightness

Adjusting the brightness (and contrast) of the picture is probably easier with a greyscale image, so you might want to set the saturation to zero for now.
The higher the gain, the brighter the picture. AGC (Automatic Gain Control) automatically adjust the gain to get a picture with acceptable brightness. AGC does not work very well for 'dark' places, so it's probably best to not use it for indoor pictures. When the brightness can not be set correctly using only the gain, change the shutterspeed. The shorter the shutter time, the darker the images. For indoor use you'll probably want to use 1/60th of a second to 1/125th of a second. For overly bright pictures (outdoor use) you'll have to decrease the shutter time to get better contrast and colors. When changing the shutterspeed it is a good idea to temporarily enable the AGC to get a reasonable impression of the right setting. Make sure to manually set the gain to the optimal setting after changing the shutterspeed.

Color

First make sure the brightness and contrast of the picture are alright.
The green component of the image is fixed to follow the saturation (as are the red and blue components, but they can be adjusted seperately later). Adjust the saturation so the green component of the image is alright, then use the red and blue balance to set the overall color of the image to your liking. When you set a balance to zero, that color (red or blue) will vanish from the picture. When you set the saturation to zero, you'll get a greyscale image. If you set it to 1, you'll think you are on drugs.

Webcam

To get a working webcam, you'll need (besides the camera of course): The internet connection is up to you, and depends among others on the number of hits per minute you get.

Webcam script

As the Indy is running IRIX (Unix), and comes with image software, the easiest way to get the webcam functionality is to write a script which performs the seperate tasks needed. Here is the webcam script I use (which should run on IRIX 5.3 or higher):
#!/bin/sh

# take picture
vidtomem -f /tmp/webcam -z 1/2 2> /dev/null

# convert to gif
#togif /tmp/webcam-00000.rgb /home/robbert/public_html/webcam.gif 2> /dev/null

# convert to jpg
imgcopy -f JFIF /tmp/webcam-00000.rgb /home/robbert/public_html/webcam.jpg 2> /dev/null

# remove picture
rm -f /tmp/webcam-00000.rgb
vidtomem takes a picture (640x480), 'zooms' in by a factor 1/2 (320x240), and writes the image to file /tmp/webcam-00000.rgb. The number and the extension are added automatically, and if the file already exists the number is increased untill an unused filename is found. The size of the file is about 775kB!
imgcopy converts the RGB-type image to a JFIF (jpeg) image in my public_html/ directory. If the image format is not specified imgcopy tries to deduct it from the given extension. A list of other image formats is given by imgformats. imgcopy seems unable to write gif images, but you can use togif instead. The size of the jpeg files is about 10Kb (320x240), for gifs it is about 30Kb (same resolution). Make sure you point the output file to the right directory and filename. If the file exists, it will be overwritten!
rm is used to remove the RGB image file so vidtomem can use the same name in the next run (otherwise the script would fail and /tmp would be full in notime).
The 2> /dev/null statements suppress any (unwanted) output.
Clean and simple!

Crontab entry

Now that we have a script which takes one picture, how do we get it to take a picture every minute? If you're running unix, and have the right privileges, this is simple: we use the cron daemon. Using the following crontab file, cron will execute your webcam script every minute:
* * * * * webcam
Read this line from left to right as follows: at every minute (*) of every hour (*) of every day (*) of every month (*) and of every day of the week (*) execute webcam.
Save this line as webcam.cron and start the webcam with crontab webcam.cron. To check your settings, use crontab -l and to stop the webcam, use crontab -r. If you are already using the cron daemon, just add the line to your crontab file. If you do not suppress output from the script, it will be mailed to you by the cron deamon every time the script runs!
A picture is taken every minute to not put too much strain on the machine and the network (my directory is mounted by the Indy via NFS, and the webserver also mounts my directory via NFS). The extra load on the machine is not noticable now (when nobody is logged in, the load stays under 0.1).

Webcam page

Last but not least, you need a nice webpage to show the picture. You'll need some special HTML code to get the browsers to update the image every minute. The simplest way to do this is to include the following line into the HEAD section of your page:
<META http-equiv="refresh" content="60">
For some more advanced examples, see the following pages: You are free to use the (javascript) code on these pages, but I would appreciate an E-mail so I can admire the end result. The java(script) pages require a java(script) capable browser, however Microsoft's Internet Explorer 3.0 is not fully compatible!

If you've got any suggestions or questions (hardware, software or camera view), please let me know!

©1999 Robbert Eggermont
robbert@ce.et.tudelft.nl