Search Flex Samples

WebCam in Flash 8 - Part I

I came across some really neat effects using a web cam as an input device... Yes, you can make flash respond to changes in a live video stream. You should check some out, they are really cool (there are some viewable demos, but you will need a web cam to interact with them):

http://incomplet.gskinner.com/index2.html#fluiddynamics
http://www.playdocam.com/

After viewing these I started thinking about how this works, and can I make it work too. I got so intrigued that I went out the other day and bought a web cam so that I can start testing these techniques.

First off, it is really easy to utilize a web cam in flash. It only takes a few lines of actionscript code to invoke the camera object. You will need a null video object on your stage... my video instance is called "video_out". Use this code to get a referrence to the camera object, set the resolution at 640x480, and the frame rate to 30 fps (if your camera supports it):

var activeCamera = Camera.get();
activeCamera.setMode(640, 480, 30);
video_out.attachVideo(activeCamera);

Next, I started looking for any information that I could find on how to detect motion within a flash video. There is a tutorial from adobe that describes a tecnique for detecting motion changes in video, but I haven't had enough time to really look into it yet (Thus the reason that this post is part 1).

Anyway... here is my progress so far. It's just a live camera feed within a swf. More changes will come as I find more time to pursue this.

Launch Live Video Test

1 comments:

Photo Masher said...

I have been messing around with webcam in flash too, I just recently started a site @ www.SillyWebcam.com to see some of my experiments (working on more).

Related Flex Samples

Learn Flex: Flex Samples | Flex Video Tutorials Flex Examples