Computer Vision: Frame differencing

In this ‘Computer Vision’ article you can read something about the Frame Differencing technique. I’ve included some video’s to give you an idea about the technique and some links the most relevant code examples.

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/LanguageResource
AS3Ostrich Flash (Flash feathers)
AS3Webcam motion detection by Soulwire
AS2Webcam Motion Detection by Guy Watson
ProcessingWebcam Piano by Memo Akten
ProcessingPoping Bubbles with OpenCV library by Andy Best
ProcessingFrame 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

  • Adhi Kusnadi

    thank u for the creative examples, by the way

    Who created these algorithms and when?