So You Want a Live Cam Eh?

The ArcterCam has changed from the original design of a live cam. Now I just take a picture and update it, but for those of you who might want to know how to have a live (or semi-live) cam, here's how to do it!

Well, it's easy, all you need is the hardware (a cam) and a net connection of some sort. What I'll lay out for you here is how to do the code to make your cam page similar to mine, ie: updating every minute, and having a datestamp on it.

Software you'll need:

That's it. Now you can do the following anyway you want, but I did it as follows:

In /etc/crontab I have the line:
* * * * * root nice /usr/local/bin/qcam.sh

This executes a script that I've created called qcam.sh every minute, of every day.

Below is the script. Note: Your milage may vary with this. Read the disclaimer at the top of the script before blindly copying and pasting.

#!/bin/bash
# /usr/local/bin/qcam.sh
# Script copyright Arcterex, 1999-forever
# Disclaimer: YMMV... I've hardcoded a few things that didn't work right for
# me, such as the parallel port (the -p 0x3bc), the brightness control (-b
# 210), and the output conversion (for some reason saving to jpg with -J
# doesn't work for me).


if [ -z $ARCTERSTATUS  ];
then

        HOURSTRING=`date +%k`;
        case $HOURSTRING in
                1|2|3|4|5|6)
                        ARCTERSTATUS="ArcterSleeping (maybe)";;
                9|10|11|12|13|14|15|16|17|18)
                        ARCTERSTATUS="ArcterWorkin";;
                *)
                        ARCTERSTATUS="The ArcterCam";;
        esac
fi

qcam -p 0x3bc -b 210 -B 6 -D -W > /tmp/pic.ppm
convert /tmp/pic.ppm JPEG:/tmp/pic2.jpg
stamp -i /tmp/pic2.jpg -o /tmp/pic.jpg -y /usr/local/stamp-1.3/standard.fnt \
	-z /usr/local/stamp-1.3/standard.fnt -s 1 -u "$ARCTERSTATUS" \
	-l "`date +%A' '%B' '%d' '%r`" 
ncftpput -u alan -p secret 192.168.1.1 /var/www/ufies/cam /tmp/pic.jpg \
 	> /dev/null 2>&1
rm -f /tmp/pic.ppm /tmp/pic.jpg /tmp/pic2.jpg

That's it!

The cron program runs qcam.sh every minute. qcam.sh takes the picture, and then based on the time, and if the environment variable $ARCTERSTATUS is set. You can set your own times, dates, and text of course. This is a very simple setup, in the future I'll modify this so that it looks at the day or other stuff as well. You can also just add a line such as ARCTERSTATUS="Gone Fishing" at the top, and that will show up instead of the time-set text.

If you don't have a full time net connection, you can set it to go out only every 10/20/60 minutes or whatever, simply by manipulating the cron line. If you have a diald setup, this can upload a picture to the net automatically. Or if you want to just do a picture a day (like the FrickCam), forego the crontab entry and just run the qcam.sh script when you want to take a picture.

The script then runs the picture through the stamp program, which puts the datestamp on the bottom and the text from $ARCTERSTATUS on top. Then it uploads the picture to a server on the Internet (in my case my firewall, 192.168.1.1).

If you want to find out how to make a remote window, or have your page refresh every minute, just take a look at the source HTML on the main page.

Easy huh?