My Profile Photo

Suhaib Khan


Software Engineer, Open Source Enthusiast


Motion detection using webcam

Recently I found an interesting article about Motion Detection Algorithms at CodeProject. It discusses about some approaches for motion detection in a continuous video stream.

Screenshot of the Motion Detector application programmed by me Screenshot of the Motion Detector application programmed by me

Inspired by this article, i decided to program an application that can detect motion in video from a webcam. Selected C#.net as the programming language and used a framework, which is specified in that article called AForge.net for image processing. AForge.net is a C# framework designed for developers and researchers in the fields of Computer Vision and Artificial Intelligence – image processing, neural networks, genetic algorithms, fuzzy logic, machine learning, robotics, etc. Its an awesome framework which can even be used by someone who doesn’t know anything about image processing.

This application works by calculating the difference between the background frame and the current frame. The resultant image is binarized using a specific threshold value. The number of white pixels in the binarized image is calculated and if this number exceeds a predetermined value, then motion is detected. These operations on image can be done easily with the help of AForge.net framework.