Here's a simple motion detector using OpenCV. My purpose was to use this program to trigger my USB connected digital camera to capture closeup images of birds, insects and rodents. But I think it is generic enough to be used for other purposes.
Read this post on sidekick.windforwings.com