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 16—the 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.
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
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
11/24/2004 1:54:31 PM