Part I: Home Automation
Because a foreach loop is used, adding an additional camera is as easy as adding
an extra unit code to the @motion_ucs array, such as my @motion_ucs = ("1",
"2", "3", "4");
Within the foreach loop, the script waits before taking the next picture to
give the wireless camera a moment to warm up. Then, the script calls the
webcam tool to create a snapshot.
The script then uses the Image::Magick module to read the picture, analyze
the brightness, adjust the levels if necessary, and then output the picture to
the correct folder. Adjusting the levels of the picture dramatically improves
the quality of pictures taken in low light. You could certainly reduce the
size and quality of the picture before saving it to improve performance when
viewing the pictures remotely; however, IDS does a great job of doing this
on the fly, so you might as well save it with whatever (generally mediocre)
quality the cameras can produce.
Image::Magick can do many different things to improve image quality, so check
out the docs at http://www.imagemagick.org/www/perl.html.
If you find that the script is reporting an image brightness of greater than 1,
it’s probably because Image::Magick is reporting an image depth lower than
the image’s actual bit depth. After upgrading to a new version of the librar-
ies, I discovered that it was reporting an 8-bit image depth, but the image
was actually 16 bits. To fix the problem (an ugly fix, admittedly), I replaced
both instances of
$grayimage->Get('depth') in the script with 16the actual
number of bits per pixel in the image. I’m guessing this is a bug, because
another user has complained of the same problem. Hopefully, it’ll be fixed
by the time this is published, so I’ll leave the original code in place.
The script uses the current time and the camera number to create the file-
name. The format is
hhmmss-#.jpg, where # is the camera number. The hours
are in 24-hour format.
Image Retrieval
The last phase of this project will enable you to retrieve your pictures from
across the Internet. You will set up a web server on your computer, config-
ure your software and hardware firewalls to forward web traffic, and finally
install IDS.
1. Install Apache
Many of the projects in this book rely on being able to remotely access your
computer. For example, in order to monitor your home security system
Image Retrieval
hhpg.indb 60
11/24/2004 1:54:31 PM

Get Home Hacking Projects for Geeks now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.