A simple webcam hooked to a computer can work well as a motion detecting security camera. I've been using them for years now with great success. I even helped the police nab a burglar one time.

I have an old desktop computer running Windows XP, but pretty much any operating system will do. My USB webcam is made by Intel ... I'm not sure if Intel still makes webcams, but another brand like Microsoft or Logitec will work great too. As for motion detecting software I use Homewatcher, but Motion on Linux is even better. Other software which sends emails when motion is detected is custom written by me in Perl.

Homewatcher takes an image once a second comparing the latest image to the previous in each case. If a difference greater than a set threshhold is detected between the two latest images, the latest image is saved. The difference threshhold can be modified to get the sensitivity right. Once a minute a custom Perl script checks for new images, and if found emails them, and moves them to an old image storage area.

Following are some images of a burglar who broke into my house one morning. My security setup worked great, sending me images at work. I passed these images along to the police who were able to apprehend the culprit shortly thereafter.

First, he acted as if he was having car trouble, and went to my front door to see if I was home.




After snooping around a while realizing I wasn't home, he returned to the front of my house where he found a 2X4.



Here he sees my camera, but it's too late ... I already have pictures of him. You can see the 2X4 in his hand which I believe he used to knock my camera off its stand which was mounted on the inside of my window.



The following Perl program checks for new images every minute and emails them if found:

use File::Basename;
use SendMail::SendMail;


rename 'c:/oldSecurityImages/mailSecurityImages.log', 'c:/oldSecurityImages/oldMailSecurityImages.log';
open(LOG, '>c:/oldSecurityImages/mailSecurityImages.log');
select(LOG); $| = 1;
select(STDOUT); $| = 1;

$baseDir = "c:/oldSecurityImages/";

$time = localtime();
print "$time ... Program started\n\n";
print LOG "$time ... Program started\n\n";

$baseDir = "c:/Program Files/HomeWatcher/Image/";
chdir "$baseDir" or die "Couldn't cd to $baseDir: $!\n";

sleep 1;

opendir(DIR, $baseDir) or die "Couldn't open dir $baseDir: $!\n";
@images = grep {/.jpg/} readdir(DIR);
closedir(DIR);

$time = localtime();

print "\n";
$time = localtime();
print "$time ... Waiting for new images\n\n";
print LOG "$time ... Waiting for new images\n\n";

$dotCount = 0;

while (1) {
  opendir(DIR, $baseDir) or die "Couldn't open dir $baseDir: $!\n";
  @images = grep {/.jpg/} readdir(DIR);
  closedir(DIR);

  sleep 3; #Wait for images to be completely written to disk

  if ($#images >= 0) {
    $smtpserver	     = "yourSMTPServer";
    $sender          = "Me <yourEmail\@yourDomain>";
    $recipient	     = "<yourEmail\@yourDomain>";
    $replyto	     = $sender;
    $header	     = "X-Mailer";
    $headervalue     = "Perl SendMail Module 1.08";

    $numImages = $#images + 1;
    if ($numImages > 1) {
      $mailbodydata = "The following $numImages images were taken";
      $subject = "$numImages New Security Cam Images";
    }
    else {
      $mailbodydata = "The following image was taken";
      $subject = "1 New Security Cam Image";
    }

    $obj = new SendMail($smtpserver);

    $obj->setDebug($obj->OFF);

    $obj->From($sender);

    $obj->Subject($subject);

    $obj->To($recipient);

    $obj->ReplyTo($replyto);

    $obj->setMailHeader($header, $headervalue);

    $obj->setMailBody($mailbodydata);

    foreach $image (@images) {
      $obj->Attach($image);
    }

    if ($obj->sendMail() > -1) {
      $time = localtime();
      print "\n\n";
      print LOG "\n\n";
      ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
      $yearMonthDay = sprintf("%02d%02d%02d", $year % 100, $mon + 1, $mday);

      if (!-e "c:/oldSecurityImages/$yearMonthDay") {
	mkdir "c:/oldSecurityImages/$yearMonthDay";
      }

      foreach $image (@images) {
	rename $image, "c:/oldSecurityImages/$yearMonthDay/$image";
	print "$time ... Emailed image $image\n";
	print LOG "$time ... Emailed image $image\n";
      }
      print "\n";
      print LOG "\n";
      $dotCount = 0;
    }
    else {
      foreach $image (@images) {
	print "$time ... Couldn't email image $image\n";
	print LOG "$time ... Couldn't email image $image\n";
      }
      print "\n";
      print LOG "\n";
    }
  }

  if($#images < 0) {
    print ".";
    print LOG ".";
    $dotCount++;
    if($dotCount>14) {
      $time = localtime();
      print " $time\n";
      print LOG " $time\n";
      $dotCount = 0;
    }
  }

  sleep 57;
}