
60
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 ...