Let me setup this scenario:
You are selling your
house.
You have small children. (Possibly 2 rug rats or more)
The real estate company calls and says they have a showing for your
house between the hours of 3pm-6pm.
You have to keep the children occupied.
You realize this is the 5th time you have shown your
house this week.
What is a programmer to do?……Setup a webcam, find a motion detection software that has support to launch a program and of course, Visual Studio 2010.
First, comes the tools
Some sort of webcam, I chose the WinBook because a friend of mine loaned it to me. It is a basic USB2.0 camera that supports 640x480 without software.
Next up was find webcam software that supports launching a program. WebcamXP support this.
VS 2010 Console Application.
A cell phone that you can check your email.
You may be asking, why write code to send the email when a lot of commercial software motion detection packages include that as base functionality. Well, first it cost money and second I don’t want the picture of the person as that probably invades privacy and as a future buyer, I don’t want someone recording me in their
house. Now onto the show...
First, the code part. We are going to create a VS2010 or whatever version you have installed and use the following code snippet.
Code Snippet
using System;
using System.Net.Mail;
using System.Net;
namespace MotionDetectionEmailer
{
class Program
{
static void Main(string[] args)
{
try
{
MailMessage m = new MailMessage
("
[email protected]",
"
[email protected]",
"Motion Detected at " + DateTime.Now,
"Someone is in the downstairs basement.");
SmtpClient client = new SmtpClient("smtp.charter.net");
client.Credentials = new NetworkCredential("mbcrump", "NOTTELLINGYOU");
client.Send(m);
}
catch (SmtpException ex)
{
Console.WriteLine("Who cares?? " + ex.ToString());
}
}
}
}
Second, Download and install wecamxp and select the option to launch an external program and you are finished.
Now, when you are at MCDonalds and can check your email on your phone, you will see when they entered the
house and you can go back home without waiting the full 3 hours. --- NICE!