Monitoring the Webcam
September 26, 2006 | 0 comments
Monitoring the Webcam
To monitor changes in the video stream captured from the webcam, you need to take regular snapshots of the video object. I use setInterval
to call a snapshot function every x milliseconds. Then, to actually determine whether there has been movement, at any moment in time two bitmaps have to be in memory—the bitmap created last time a snapshot was taken (“before”) and a bitmap containing the current state of the video (“now”). Using the BitmapData
class you can then compare the two bitmaps:
import flash.geom.Matrix
import flash.display.BitmapData
setInterval(this,"snapshot",100);
now=new BitmapData(output_vid.width,output_vid.height);
m=new Matrix();
function snapshot()
{
now.draw(output_vid,m);
//…… code that check's difference between 'now' and 'before'
before=now.clone();
}
Comments