Monday, July 21, 2008

Actionscript 3.0 Webcam Motion Detection with Interaction Physics



Actionscript 3 application that performs motion tracking via webcam.

The application works by constantly monitoring a webcam, taking snapshots of each frame. Those frames are then constantly drawn to a bitmap data object. The difference in brightness within each segment (from one calculation to the next) determines whether or not motion had occurred in this area of the screen. If motion is detected the coordinates of a rectangular grid around said motion is recorded. To track whether or not the "ball" has been effected, the current x and y coordinates of the rectangle to the coordinates of the ball. The direction of the ball is determined by again comparing the points of the motion area to the "ball" point.


Try it for yourself here. (webcam obv required)

No comments: