Thursday, October 7th, 2010

Passing Webcam Data into WebGL via Flash

Category: Flash, WebGL

<p>File this one in the crazy cool hacks category. Peter Nitsch has been experimenting with using Flash to access a user’s webcam, and then feeding this data into WebGL:

I tend to stay away from the HTML5 vs Flash “debate”, principally because I think it’s inane. Both platforms offer certain advantages over the other and some interesting results can be achieved by utilizing their strengths. Case in point, Flash’s built-in webcam support and WebGL’s hardware-accelerated 3D graphics are features that only exist in their respective platforms (for now). Bridging the technologies produces something unattainable by only using one, as the following quick examples illustrate.

How does he integrate these two technologies?

Passing webcam data to Javascript involves a few steps. The BitmapData drawn from the Video object needs to be compressed to JPEG and encoded to Base64 for the data URI to read it. This can be a very taxing process in native ActionScript, but is nearly negligible when done in haXe orAlchemy. In this case, I’m using both. The JPEG compression is performed by metalbot’s Alchemy JPEG encoder, while the Base64 encoding is handled by Bloodhound’s haXe crypto library.

Peter then uses Flash’s ExternalInterface to pass the string back to JavaScript and turns the webcam JPEG output into a data URL that can be fed into an HTML Image tag and fed into WebGL. Craziness!

[Via http://www.eleqtriq.com/]

Related Content:

1 Comment »

Comments feed TrackBack URI

Another opportunity to show that flash is no longer nedeed for anything:
http://www.youtube.com/watch?v=WcwnQW_AnC8&feature=player_embedded

Comment by Jimaral — October 11, 2010

Leave a comment

You must be logged in to post a comment.