My QuickCam on Linux
 
QuickCam Here comes a short description on how I set up my camera with RedHat Linux. At first it was just plain curiousity, but because it seems to work very stable so why not post the image at the web.... This was written the 22nd of november 1998 so some of it might be a bit obsolete, but I still use the same setup today. :)

The equipment I used to set this up is:

  • Connectix Color Quickcam
  • An Intel 486DX2-66 computer with:
  • 32Mb memory, 650Mb HD and
  • RedHat Linux 5.2

Installation

First of all I installed the RedHat Linux on the computer and did the upgrades as recomended in the RedHat errata. Then I attached the Quickcam to the paralellport and downloaded the software to control the camera called cqcam. The package is unpacked with (filename changes with versionnumber):

tar -zxvf cqcam-0.90pre4.tgz

Originally I was not interested in the X-versions of the program, but if you want to install these it requires libX11 and libXext. The command line part of cqcam only requires libc, but GTK+ library is recommended. Also libjpeg v.6 or newer are required to make .jpg-images.

Please read the enclosed textfile before preparing the build, as root, by typing "./configure" which guess values for system-dependent variables and create Makefiles. Examine the "Makefile" and type "make" to build the binaries and "make install" to install them.

Take a picture

As mentioned, I was primary interested in the command line program. And after cqcam was compiled and installed I tried to take a picture by running the following command from within the directory where the binary executables are installed:

./cqcam > /home/httpd/html/mycam.jpg

Then I launched a browser to check what this really looked like. (Well I have Apache installed on the Linux machine, "Spiff", and "/home/httpd/html" is the web-root so I pointed the browser at: "http://spiff/mycam.jpg". Believe it or not, but there was actually a picture! :)

Some adjustments

But the grabbed picture was rather dark, so I had to make some adjustments. To check out all the options, read the manpage. My camera is placed in my windows, and in daylight I now use these options:  

./cqcam -32- -j -l 5 -s 1 > /home/httpd/mycam.jpg

In shortly this meens that cqcam runs in 24 bit color mode, make jpg-file, cut of 5 lines and a scalefactor on one. But when it gets darker outside the grabbed picture's quality is poor. So at night I use these options (on one line):

./cqcam -32- -j -l 5 -b 235 -B 128 -S 128 -w 160 -H 15 -s 1 > /home/httpd/mycam.jpg

In addition to the daytime options this means that I use a brightness level of 235, a blacklevel of 128, a saturation level of 128, a white level of 160 and hue (blue level) of 15.

Handy stuff

As you can see on my picture I also have the date and time in the bottom right corner. This is done by a little application called Stamp  Download, extract and build this (here is my build on RH5.2) (see the README-file(s) for info) and run it with the following command:

./stamp /home/httpd/mycam.jpg /home/httpd/newpic.jpg

As you see this creates a new picture with a different name. To make all this work by itself I've made som small scripts, one is used when it's normal daylight an one at night with the options as mentioned above. Here is the daylight script:

#!/bin/bash
#
# This script takes a picture with the QuickCam.
# Brightness and contrast are adjusted for daytime use.
#

# Robert Grefstad, robert@_nospam_grefstad.com, 19981122

# Set location of the binaries
BINDIR="/usr/local/quickcam"
STAMPDIR="/usr/local/stamp"

PICTMP="/usr/local/quickcam"
PICDIR="/home/httpd/html"

$BINDIR/cqcam -32- -j -l 5 -s 1 > $PICTMP/newpic.jpg
sleep 1
rm -f $BINDIR/images/mycam.jpg
$STAMPDIR/stamp $PICTMP/newpic.jpg $PICTMP/mycam.jpg
rm -f $PICTMP/newpic.jpg

sleep 1

if [ -f $PICTMP/mycam.jpg ];
then
  cp -f $PICTMP/mycam.jpg $PICDIR
  # Pictures taken and stamped
  exit 0
else
  $STAMPDIR/stamp $PICTMP/nocamera.jpg $PICTMP/mycam.jpg
  cp -f $PICTMP/mycam.jpg $PICDIR
  #No camera attached, stamped dummy instead
fi


# End of script

If the camera is not attached or it does'nt work properly, the image from cqcam is zero bytes, and the image after running stamp does not exist. Then it stamps a dummy-picture called "nocamera.jpg" and copies to the webserver instead. This dummypicture is really just a picture with the same size as the original picture with a text like "Sorry, no camera attached...)

Also I have a similar script with the parameters that run's at night. Both are runned from cron with these to lines in "/etc/crontab":

# Taking a pic w/QuickCam. Script adjusted for day-light.
*/2 10-15 * * * root /usr/local/quickcam/camscript.day &>/dev/null

# Taking a pic w/QuickCam. Script adjusted for night-light.
*/2 16-23,0-9 * * * root /usr/local/quickcam/camscript.night &>/dev/null

This script is all that needs if the web-server is connected directly to the internet. But because I use a dial-up connection I've made som other scripts as well that checks if my ppp-link is up, and then uploads the image using ftp.

Links

 
 
Design 19©96-20©03, Robert Grefstad