I use a very simple mechanism:
- Load the picture from the video capture buffer into a bitmap structure
(this is the reference image)
- Wait a couple of frames - depending on how sensitive the motion detection
needs to be. At a framerate of 10 fps, wait 5 frames to check every half
- Load frame into another bmp structure.
- Check the pixels one by one comparing the pixel on frame 1 to the pixel on
frame 2. For less sensitive application, and to go faster, check every tenth
of 50th pixel. This is fine to detect a person moving across the screen for
- To check the pixels, do a pixelref = (red value + green value + blue
value)/3 pixelcheck = (red value + green value + blue value)/3.
Difference = abs(pixelref-pixelcheck).
- Compare the Difference to some variable you set (I call it
SignificantDifference) indicating that the two pixels are quite different in
- Count the number of pixels with significant differences until some
threshold is reached - which then tells you there's motion - and you can
exit the loop immediately.
- If you reach the end of the loop, with no significant count, then you know
the two images are very much the same.
I get good results with the following parameters with 388 x 244 video to
detect a person walking past the camera:
- Check every 100th pixel (94672 pixels in total -so I check 1% of pixels)
- The pixels are significantly different if the (r+g+b)/3 > 50.
- If I get more than 10% such pixels, I know there's motion.
You can play with the sensitivity by changing the above parameters.
You can find a lot of info re video at http://www.veryComputer.com/
>Am currently working on a school project, trying to develop a motion
>detector from software using commercially available *s, and after
>searching for about three weeks I found your site.
>Am really looking for information on how to compare clips from an avi steam
>taken from a Logitech camera, in order to develop a basic software motion
>Any help will appreciate
>San Juan, Puerto Rico