Build 10 games and learn game development along the way in this fast paced game development course

Get the source code of 12 commercial games, loaded 50+ million times, and learn the secrets of game design

Learn how to make a successful Flash game from a real world example. Fully commented source code

Create realistic Flash physics games from scratch with advanced features, from Angry Birds to Crush the Castle

Flash AS3 face detection and recognition library

Today I am showing you a nice AS3 library which allows face detection and recognition in a photo. I already blogged about a similar topic in PHP face detection class post, but this time we’ll work with AS3 and face recognition.

You may say: is there a difference between face detection and face recognition? Or are you just using these words randomly?

There is a slight difference, let me explain:

Face detection looks for some features which distinguish an human face from the rest of stuff in a photograpy: usually when we have a pair of eyes, nose, and a mouth we may say we are in front of a face (ok, I made it a bit simpler than it really is, but this is the concept behind it). Let’s think about the Facebook tag option when you upload a new photo.

Face recognition looks for A SPECIFIC face in a photo, just like cameras in an airport looking for some most wanted terrorist faces. With some tweakings, face recognition can be used as face detection.

Oskar Wicha’s ActionScript 3 library allow us to do both things using Eigenfaces concept, basically some patterns which should match a human face.

The following script wants the path of an image in the input text at the bottom of the stage and once you click anywhere, it loads the image and places a tag on any face it recognizes.

And you will get something like that:

It’s just an image because I cannot load external image due to cross domain policy, but try it by yourself, just enter an url and click with the mouse anywhere we running your Flash IDE

Remember that face detection and recognition could be no that accurate, so in some cases it will miss faces, in some other cases it will detect false positive faces.

Download the source code with the library and a zipped file with Eigenfaces data which must be placed in the same folder of your main file. Also, you’ll probably have to customize the path to your FaceRecognitionLib.swc library.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (11 votes, average: 4.27 out of 5)
Loading ... Loading ...
Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 12 comments

  1. Me

    on September 26, 2013 at 3:49 pm

    Why you dont have a contact page?
    Or maybe I cant see it?
    I suggest you adding email or contact page on your homepage.
    On that way someone can send you message, not only post a comment.

  2. IPN

    on September 26, 2013 at 5:00 pm

    The main question is how to use this lib on mobile devices with camera and detect faces in real time.

  3. Victoria

    on September 30, 2013 at 11:58 am

    Wow, it looks really promising, the especially interesting thing is recognition – I wonder where do they take the “library” of faces to recognize and if it will work on normal people (not celebrities, or someone well known)

  4. help :/

    on October 3, 2013 at 9:34 am

    Hi, I tried using the exact same code you provided but the faces are not detected. the faces.zip file is in the same folder. how do i fix this?

  5. oscyloskop

    on October 3, 2013 at 2:38 pm

    Hi Victoria,

    to create “library” of recognizable faces by your app, you need to use function of class FaceRecognizer called loadTrainingFaces which takes as parammeters faces clasiffiers (for example person name) and url to face image. For correct recognitions 5 images of each face in training set are required. Good example showing how to do this is Example 2 in download section of project page https://code.google.com/p/face-recognition-library-as3/downloads/list

    Have fun coding.

    Oskar
    (aka author of FaceRecognitionLib)

  6. oscyloskop

    on October 7, 2013 at 3:39 pm

    Problem with this example is probably caused by the fact that image is loaded to detector before event listeners are added.

  7. Sidd

    on October 23, 2013 at 4:25 pm

    I have a problem I was try the code in my flash cs5 version but cannot run it gives me two error both are same
    “G:\www\birthday\FaceRecognitionLib\Main.as, Line 64 1046: Type was not found or was not a compile-time constant: FaceDetectorEvent.”

    Is that will work with cs5 if not from whre I can find out a face detection for flash cs5
    Sidd

  8. oscyloskop

    on October 25, 2013 at 7:08 pm

    Hi Sidd,

    First version of library worked for sure witch Flash CS5.
    Good starting point for you would be Jaron tutorial:
    http://dev.tutsplus.com/tutorials/automatically-tag-photos-with-the-as3-face-recognition-library–active-9033

    He was using older version of library but public interface of library is almost the same.

    To my it sounds like error caused by writing noFacesDetected(FaceDetectorEvent) insted of noFacesDetected(e:FaceDetectorEvent).

    If not, read Jaron tutorials and comments and all should be clear.

  9. HB

    on November 13, 2013 at 11:44 am

    I would like to use the library to detect (approximately) the position of the eyes … is this possible? how? (it is not to recognize a familiar face but if a face is detected (FaceDetectorEvent.FACE_CROPPED) to obtain the coordinates of the eyes on the face). THANK YOU

    Henri Blum

  10. List of 50+ Face Detection / Recognition APIs, libraries, and software « eTone Tech.

    on January 17, 2014 at 5:07 am

    […] Flash AS3 face detection and recognition library - Oskar Wicha’s ActionScript 3 library allow us to do both things using Eigenfaces concept, basically some patterns which should match a human face. […]

  11. 56 ?????/???API????? | ????

    on May 22, 2014 at 3:32 am

    […] Flash AS3 face detection and recognition library – Oskar Wicha’s ActionScript 3 library ??????Eigenfaces??????????????? […]

  12. ???????API????????????????? | NegativeMindException

    on June 17, 2014 at 5:04 pm

    […] Flash AS3 face detection and recognition library – Oskar Wicha’s ActionScript 3 library allow us to do both things using Eigenfaces concept, basically some patterns which should match a human face. […]

Thank you for the download!!

I hope you will find it useful and make something interesting out of it

To keep up to date with the blog, why don't you like my Facebook page and follow me on Twitter?

Want to learn more? Don't miss this:

Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now

×