Real Drawing to Augmented Reality

Augmented reality may prove to just be a flash in the pan trend in the Flash world, but let’s face it – it’s fun. So, that in mind, here’s a little something I was just fiddling around with: a small app that takes an actual drawing (as in pen and paper – you know – analog) and converts it into a 3d augmented reality thingamajig.

To give it a try below:

  • Print out this marker (ignore the left hand / right hand bs. That was for another project and I was too lazy to create a new marker image).
  • Make a small drawing on a piece of paper. You can use colours, but keep the contrast as high as possible (a black drawing on white paper will work best, but not be very interesting).
  • Double click on the app below and allow webcam access. Hold your drawing up so that it fits nicely into the red square then hit the space bar.
  • When the app tells you to, put down your drawing and hold up the marker you printed out to see your work of art hover in 3 dimensions in front of your face.
  • Be amazed…
  • If you don’t want to go through all that hassle, just check out the demo video down below using a picture of a scary Halloween jack-o-lantern I drew with my wife’s crayons (shhh.. don’t tell her I got ‘em).

Get Adobe Flash player

Demo:

Get Adobe Flash player

THE GEEK SHITE:

For anyone interested, here’s what’s going on under the hood. When you hit the space bar, the app takes two quick pics: one “what you see is what you get”, the other, 100% black and white contrast using Quasimondo’s handy “automated threshold and edge detection” gadgetry. The white in the black and white image is converted to alpha (felt like I was coding like a caveman at this point – looping through the vector of pixel values and replacing each white pixel with a transparent pixel, one by one. If anyone knows a quicker/smarter way of converting white pixels to transparent in BitmapData, please post a solution). The alpha channel of the black and white image is then copied to the color image. A Bitmap instance is created from that BitmapData and then passed on to an image extruder like I rambled on about here. That 3d object is then passed on to a Papervision3d/FLAR scene and that’s that. Fun stuff.

3 Comments »

  1. Tom Richardson says:

    You should be able to easily use the “threshold” function for BitmapData to convert pixels to any color you like. The following will copy all non-white pixels to a blank BitmapData (you could then do your copyChannel if you like)

    targetBitmapData.threshold(sourceBitmapData, sourceBitmapData.rect, new Point(0,0), “==”, 0xFFFFFFFF, 0x00FFFFFF, 0xFFFFFFFF, true);

  2. Devon O. says:

    Beautiful, Tom. Thank you for that. Threshold didn’t even occur to me – I was thinking maybe floodFill., but threshold would be better.

  3. skaale says:

    Very cool techn. it it possible to have a look at the source, would be cool to get a little bit wiser on AR??

RSS feed for comments on this post. / TrackBack URI

Leave a Reply

Devon O. Wolfgang

Technical Reviewer of “The Essential Guide to Flash CS4 AIR Development”

Contributing Author of “Flash AS3 for Interactive Agencies”

Senior Software Developer in Dublin, Ireland

Portfolio

Bayer Pixel Bender Filter

Bayer Mosaic Filter in Pixel Bender


Now, seeing as how I’ve been trying to learn some Pixel Bender coding lately[...]

Liquitext

Liquid Text Effect


Haven’t been too active around here lately due to a major on going project at work lately as well as the fact that my wife and I are in the slow process of moving homes. Really, the only free time it seems I have these days is during the lunch hour. So, over the past two days, I came up with this fun little toy during lunches[...]

Google’s Text To Speech Engine in Flash

I’m not sure how I managed to miss this, but I just happened to run across a ‘new’ (well, newish), albeit still unofficial, offering of Google today: text-to-speech. You can see what few details there are on this Techcrunch post. Basically, it just boils down to this though – you send your phrase to be [...]

Quick Sound Effects Generator


Need some beeps, boops, or bops, to go with your UI or games [...]

Quick QuickBox2D Tip II – Collision Detection

Custom collision detection/handling in QuickBox2D [...]

None of This Runs Eternal


No Flash/Actionscript stuff here. Just me rambling about the upcoming Current 93 concert [...]

Playing Around with the New UndoManager

Included in the Flex 4.0 SDK and the, just released, Flash Professional CS5 lies a new hidden little gem of a class: flashx.undo.UndoManager (although the Flex 4.0 SDK’s been out for awhile, I have to admit I didn’t even notice this until I installed Flash CS5 and started poking around the documentation looking for new [...]

Making Waves

In a previous post, “Digging into the Microphone in Flash Player 10.1″, reader David Law asked in the comments how it would be possible to save .wav files to the server. I wasn’t sure right offhand, but thought I’d spend my lunch hour yesterday looking into it. Well, after reading this quick tutorial on Adobe [...]

Some Drawing Fun and a Bad Movie You’ll Never See

Earlier today, Dave Gillem posted a link on Facebook to an incredible Processing based drawing application. Thought I’d have a go at reproducing something similar in Flash. Well, I failed miserably, but the results were still interesting enough to check out. You can play around with it below. Just mouse down to draw in the [...]

Animating Bezier Curves


The other day I got the notion in my head that I wanted to draw some bezier curves in an animated fashion. I’m sure this has been done a million times before, but sometimes reinventing the wheel can be a good learning experience [...]

My God, It’s Full of Stars…


Just a quick little thing I got an idea for (i.e. pretty much ripped off) while browsing Processing examples.

Another Year, Another Look

As a few folks may have noticed, the blog is looking a little bit different as of today [...]

The Webcam Warholizer


Just a little bit of quick Friday fun with webcam and bitmapata…

More With the JiglibFlash Terrain

Playing around a bit more with the animated JiglibFlash terrain idea from my last post, I wanted to see how it would work in conjunction with a webcam. So, needless to say, you’ll need a webcam to check out the results below.

Rockin and Rollin with the JiglibFlash Terrain


Finally got the chance to play around with the new JiglibFlash height map terrain, today, and have to say I am very impressed [...]