Welcome back to the 90ies!
A few days ago, I took 20 minutes when I was bored and not really able to concentrate on my work, to set up a webcam feed to my laboratory desk. Here is the setup, for those interested (this is very basic stuff, but may interest those who are still beginning to explore their computers):
Ingredients:
- An ubuntu box connected to the lan - root access (my computer)
- A debian box connected to the internets - no root access (the lab’s web server)
- A logitech webcam (forgot the exact model right now)
How to prepare:
A few years ago, I read many terrifying reports about the state of webcam support on linux. Seems that those dark ages are over, because my ubuntu box recognized my rather old webcam with no intervention from my part.
I apt-get’ed the “webcam” package in my personal box. The binary takes pictures from the webcam at regular intervals (settable in the .rc), and saves it to the indicated place in the filesystem. It has an option to automatically upload the picture via ssh or ftp, but that requires either leaving the password in plain text in the configuration file, or manually entering the password all the time, neither of which are acceptable alternatives.
So instead I installed apache at my machine, and saved the picture from “webcam” into the www folder. I would find a way to grab it from the server machine. The simplest way to do it is to use wget. At first I put wget into the crontab file, but the lowest resolution of the crontab file was 1-minute updates, and I was aiming for 5-second updates.
So instead, I created a small script:
while [ 0 -lt 1 ]
do
wget -q mybox myboxaddress/picture.jpg -O public_html/picture.jpg
sleep 5
done
And left that script running in the background (under nohup, so that it wouldn’t be ended after I logged off the computer).
Now, I have a picture in my public page which refreshes every 5 seconds - I just need an autorefreshing page to go with it (because clicking the refresh button all the time is boring). The way to do this in pure html is to add the following tag in your “head” section:
meta http-equiv=”refresh” content=”5″
(this must be in brackets, but silly wordpress won’t let me do it
)
This tells the browser to automatically refresh the page every 5 seconds - don’t make your page too heavy!
And there you go! You’re really to be the new Jennycam!
Now I just need to use all this energy to finish my paper
Comments
This is a very simple and somewhat crude solution. The shell script to wget/sleep particularly bothers me. If anyone has a more elegant solution (maybe the reloading webpage grabs the picture from my box when requested via php? Which would be more computationally expensive?) I would like to hear it.
June 25th, 2009 at 1:09 pm
Hi Claus,
You could have used cron instead of the infinite loop.
But as you say, it is just a crude solution.
June 26th, 2009 at 5:44 pm
Drebes,
Read it again
I tried to use cron, but I wanted 5-second updates, and cron goes only up to 1-minute updates.