GardenCam

Our webcam overlooks our garden just outside Sheffield (UK). The server that hosts it runs 24/7 and so does gardencam. The only thing that should upset is is if the broadband connection fails. Each time you request this page, it fetches a new image from the camera using a php script and date and time stamps it.



After many iterations of different equipment, webcams and hosts, gardencam hopefully now has its final resting place with the purchase of a D-Link DCS900 network camera. This way, it's OS independant and not reliant on changing USB support and camera chips.

The server hosting gardencam's web site is a SuSE 9.3 Linux machine running Apache2/PHP which is also used as a desktop, mySQL host, DHCP for our LAN... loads of things in fact!

Everything is behind a separate Linux firewall, so nothing is really on the Internet at all - just to keep the Bad Guys at bay.

Coming soon

Thanks to the loads of people that have suggested ways of making gardencam videos. I did write about it in my blog some time ago but seeing as there was no link between this and the blog, (kind) people just kept on writing.

If you can't be bothered to read the blog, the answer was mencoder, part of the MPlayer suite. There's a command line option which will take a grop of jpgs and convert them to an mpeg video. The DCS900 images were a bit funny though and the conversion didn't work first off. To fix the problem, I ran all the images through convert (part of ImageMagick) first which fixed up the jpegs so mencoder could do it's job. The jpg capture was easy - a quick bash script that using wget to capture the image once a minute or so and dump it to a file in a temp directory with a filename based on the timestamp.

As an aside, I've just put an application together using mencoder do do live capture of images from a vacuum arc remelt furnace via a pair of cameras and Hauppauge PVR150 capture cards on Linux. This should enable out metallurgists to watch the molten metal pool for nasties. It's soft porn for metallurgists... not my idea of a pleasant night's TV viewing :-)

The php that drives me...

This is the script that drives gardencam. I use this in an 'img' tag in the page you're looking at now. The URL in the @imagecreatefromjpg(...) function is the internal address of my camera.

<?php

$im = @imagecreatefromjpeg("http://192.168.199.6/image.jpg");
$background = imagecolorallocate($im, 127, 127, 127);
$textcol = imagecolorallocate($im, 255, 255, 255);

$dimx = imagesx($im);
$dimy = imagesy($im);

imagefilledrectangle($im, 0, 0, $dimx - 1, 20, $background);

$currdate = date("d-M-y H:i:s");
$txt = $currdate . " www.gardencam.co.uk (c) David Morris";
imagestring($im, 5, 5, 0, $txt, $textcol);

header("Content-type: image/jpeg");
echo imagejpeg($im, "", 100);
?>