How to Make a Motion Detector Using AForge
Motion detection in computer video analysis involves using various algorithms for detecting motion in video on a frame-by-frame basis. AForge.NET is a C# library that programmers can use to implement these algorithms easily and build their own motion detector. At its simplest level, a motion detection algorithm involves comparing two scenes and determining if changes exist from one scene to the next. It may do this analysis at the pixel level or on a broader scale. If substantial changes exist, then the algorithm infers that there is motion in the scene and can highlight the moving object.
Instructions
-
-
1
Download and install the latest edition of Visual C# Express edition, which you will need to build the motion detector in AForge.NET. The express edition of Visual C# can be freely downloaded from Microsoft’s website. While it is a scaled down version of Visual Studio, it provides more than enough power and features for the average programmer to build robust applications.
-
2
Download and install the latest edition of Aforge.NET Framework library at its website. Take note of where Aforge.NET installs on your hard drive, as you will need to know this location to use some of the sample code for the motion detector.
-
-
3
Start Visual C# Express edition. In the application menu click "File." From the drop down menu below it, click "Open Project." Navigate to the folder where Aforge.NET installed on your hard drive. Typically it will install under Program Files. Navigate to the AForge.NET | Samples | Vision | Motion Detector folder. Select the MotionDetector C# solution file project in this folder and click "Open."
-
4
In your Visual C# application menu click "Debug." From your drop down menu click "Start Debugging" to run the sample application.
-
5
With the Motion Detector application running, click "File." From the drop down menu below click "Open." Navigate to the location which contains the sample AVI file that has the video you want analyzed for motion detection. Select the file and click "Open." Immediately the Motion Detector application will play the video and start applying colored markings in frames of the video where motion has been detected.
-
6
Experiment with the the Motion Detector application. Click "Motion" on the application menu. From the drop down menu click "Motion Detection Algorithm" and a fly out menu will appear. Click "Two Frames Difference" to implement a simple motion detection algorithm involving a simple comparison between one frame and the next. In the same fly out menu, click "Simple Background Modeling" to demonstrate an algorithm that uses a frame's background as the reference point for analysis.
-
7
Experiment with the different shading operations for the Motion Detector application. Click "Motion" and then click "Motion Motion Processing Algorithm" in the drop down menu.
-
1
References
Resources
- Photo Credit Hemera Technologies/AbleStock.com/Getty Images