Computer Vision : Frame differencing

Frame differencing is a technique where the computer checks the difference between two video frames. If the pixels have changed there apparently was something changing in the image (moving for example). Most techniques work with some blur and threshold, to distict real movement from noise. Because frame could differ too when light conditions in a room change ( and camera auto focus, brightness correction etc. ). Below an example of the difference filter in the OpenCV library for Processing. You can do the same in Flash with the Difference Blendmode. You can move objects to area’s where most of the motion is happening, like in the Pong example of Ostrich : Ostrich two cursors example Or you can make some hotspots in your image and check the amount of motion in those. A nice example to get the idea is the webcam piano from Memo Akten (implemented in Quartz Composer and Processing) : Or you can do other creative things with it (video by WTF? by OK Go, example code in Processing by Memo Akten) :

Code examples and tutorials

Tool/Language Resource
AS3 Ostrich Flash (Flash feathers)
AS3 Webcam motion detection by Soulwire
AS2 Webcam Motion Detection by Guy Watson
Processing Webcam Piano by Memo Akten
Processing Poping Bubbles with OpenCV library by Andy Best
Processing Frame differencing code example by Golan Levin

If you only want to detect if there is a certain amount of motion in front of a webcam, you can use the activityHandler and activityLevel parameters in Flash. See my example on bitmap filters where i use it the apply a red filter when there is movement :
Flash AS3 : Apply bitmap filters to a webcam image