Multiple Motion Areas in Flash Motion Detection

Motion detection in Flash relies on a technique that uses frame comparison to detect whether pixels have changed within the camera feed. A “comparison” frame would look something like the image below, where the white areas indicate movement or a change in pixel value.

Using the getColorBoundsRect() method, the application can approximate which areas of the video has motion. Using the example above, I would call the getColorBoundsRect() method to look for white pixels in the BitmapData. This is all fine and dandy, but I was curious to see what performance was like if I was to try and get the position and size of each individual blob in the comparison frame.

Here’s the result of the experiment:

This movie requires Flash Player 9

After this test, it was interesting to see the amount of data that we can extract with this method. The demo returns a list of Rectangle objects every frame, which means that we now have x,y positions and size for every bit of motion that occurs within the frame. I think the next step is to see whether we can write something that checks the distance between these small areas and try to detect some simple gestures.