Merging MariLena and Papervision 3D to an Augmented Reality App in AS3

Again I have got the opportunity to play around with 3D in Flash and the tracking of objects within bitmap-data of webcam images. One year ago I already built my own tracking engine in AS3 for markers, but not for faces. So I was glad to find new stuff out there.

Having searched the Internet for "Face Detection" I stumbled over two projects that caught my attention:

1. Real-time Face Detection in Flash
2. Demo of Adobe Flash Face Recognition using the openCV port to AS3

Both are using the MariLena AS3 library which was ported from OpenCV.

Since I really like Papervision 3D I decided to put Marilena and PV3D together. See screenshot below or download it (you need a webcam using it).

The cow will follow your face, rotate her by moving the mouse. Click on the cow to roll her.

Credits: The collada model is from a 3d tutorial of Papervision2. The AS3 programming has been done with FlashDevelop.

Download the source code to play around yourself:

Or read it online:

Source Code

Source Code

Note: The webcam image is mirrored so that it behaves like a real mirror. You can do this using a matrix:
var ma:Matrix = video.transform.matrix;
// flip horizontal assuming that scaleX is currently 1
ma.a = -1;
// apply the mirror matrix to the display object
ma.tx = video.width + video.x;
video.transform.matrix = ma;

Extension II: Virtual Mirror with Glasses

I used SketchUp to built three glasses and imported them as Collada 3D objects into my application, now we have a prototype of a virtual mirror - you can download it here:

Here is the source code for the virtual mirror application:


Og2t hat gesagt…
Nice one, I am working on something similar at
Anonym hat gesagt…
dude were's your facebook at :)
Sérgio Silva hat gesagt…
Hello, Great work, do you think its possible to use the tracking Marilena to track a road line and signs? my ideia it's to build a autonomous driving system using AS3.
blckfire hat gesagt…
Marilena is only able to detect objects based on haar features and haar cascade classifiers if I'm not mistaken. I improved the library a little bit, please check:
Anonym hat gesagt…
hi,just want to ask..i had downloaded the source code,but how do i apply it to flash?cause the source code is in actionscript file...and the testing movie is not available..
Kajus hat gesagt…
The programming has been done with FlashDevelop. The packed file contains the according project files to compile.
Anonym hat gesagt…
thanks for the help,but i got the error 5007:anactionscript must at least have one external visible definition.
Anonym hat gesagt… you mind placing the second application source code as well? thanks!!:)
Anonym hat gesagt…
Do you mind posting source for the second example too? That would be much appreciated!
Kajus hat gesagt…
source code published :)
Anonym hat gesagt…
can this marilena work with XML data?
Nabawi hat gesagt…
what if I want to change its object .. I've tried but an error occurs
Kajus hat gesagt…
Currently I'm not developping this project any further. You might want to contact the MariLena developer or find related projects.
Anonym hat gesagt…
Hi there, great work, I already tried the first one, but why is the cow's material is missing in the flash player after built, before the built, the material is still show, but after the compilation it's missing ?
Nabawi hat gesagt…
how can be displayed on the web online .. I tried but failed
Maria del Carmen Morales hat gesagt…
Hello, great work congratulation... this link is broken, please.. can you upload again.. thank you...
Kajus hat gesagt…
Thanks for pointing out. Should be fixed now.