Eightlines Creations

Experiments in Physical Computing

Thinking out loud — Arduino as Webcam

Lately much of my work has been dealing with getting Flash to talk to the Arduino. There’s no real functionality to do this on its own, so you have to rely on some other components to host the conversation. There’s a whole host of methods you can use here:

  • Socket Connection - This requires a socket policy to be set up on the server or else you’ll get a nasty SecurityError. I used Processing to open the connection, and Flash connects to that socket. Check out this version by Mikko Haapoja which uses Processing to generate OpenGL and pass it to Flash as a ByteArray. You pass bytes from here. Also check out AS3Glue which extends the Socket Connection.
  • Merapi - This bridges Java and Flash. 
  • Serproxy - Included with Arduino, different versions for Mac/Win/Linux. I had difficulty with Serproxy on a Mac and had to switch to a Java version.
All of these work, but the issue is that it still requires a second piece of software to be installed to mediate the connection. In an ideal world it would be nice if Flash could handle the Serial connection itself. This would probably fall under the AIR umbrella in order to properly handle the security permissions. 
From what I understand this is a common request to Adobe, and there’s no date that has been set for the feature. This has got me thinking if there’s a way to do it ourselves. (Note: I have no experience writing drivers, so I’m just speculating at this point.)
The general idea is to write a driver that would fool the OS into thinking the Arduino is a webcam. With Flash having native support for the webcam, content sent from the Arduino would be received through the Camera class (which is Final, so we can’t extend it). The video object would connect to Camera and interpret the transmission as a ByteArray. Theoretically, this would only give us Read ability. 
This still leaves us with another piece of software to install, so in the end we’re no further ahead than we were using a proxy connection.
Before I dig in and figure out how to build a webcam driver, anyone have any input? Has anyone produced a simillar project? I’ve been searching for a while now and haven’t come up with any useful information. 

Search

The archives run deep. Feel free to search older content using topic keywords.