Archive for the ‘Scripting & Programming’ Category

Multiple Webcams in Flash with Actionscript 3

Tuesday, June 9th, 2009

picture-37

It’s true! You can have multiple webcam feeds in your swf/as3 application. Here’s how:

  1. Plug in your webcams.
  2. Look in your Flash Player’s Camera Settings Panel. You might have to open an existing swf to get here. You should see a dropdown list of all the cameras available to you. The first camera on the list is camera 0, the second is camera 1, and so on. Remember the numbers of the cameras you want to work with (In my case, I want #7 and #8).
    Flash Player's Camera Settings
  3. Call your cameras with Actionscript 3. Here’s the code, and here’s a FLEX project.The Actionscript 3 Code
  4. A few pointers: be careful about plugging/unplugging the cameras. Flash Player seems not to like this, you may have to quit and restart to refresh the list. You can adjust how and where both video feeds are placed in the scene. In this example they’re layered on top of each other with the blend mode set to OVERLAY, which [sort of] averages the two feeds together.
  5. Only see one camera? Depending on your camera & drivers, your computer may not recognize two identical cameras at the same time. Cameras with different hardware should be recognized, though.

Also, I am using Playstation 3 Eye cameras, because they are great in low light and have high frame rates, and are pretty cheap. You can get drivers for Windows and Mac since they are not recognized automatically. Have fun!