-
Notifications
You must be signed in to change notification settings - Fork 16
M.3 Detect Faces
With ML Kit's face detection API, you can detect faces in an image, identify key facial features, and get the contours of detected faces.
With face detection, you can get the information you need to perform tasks like embellishing selfies and portraits, or generating avatars from a user's photo. Because ML Kit can perform face detection in real time, you can use it in applications like video chat or games that respond to the player's expressions.
NOTICE: This is a beta release of ML Kit for Firebase. This API might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.
import com.myflashlab.air.extensions.firebase.mlkit.*;
// initialize ML Kit AFTER FirebaseCore is successfully started
Mlkit.init();
/*
You can create VisionImage instance from BitmapData, File or ByteArray
Mlkit.createVisionImageFromBitmapData
Mlkit.createVisionImageFromFile
Mlkit.createVisionImageFromBytes
*/
var image:File = File.applicationDirectory.resolvePath("img.jpg");
// This is beta version and for some reason, creating vision
// images from file is not working! instead you may use
// BitmapData for now!
var loader:Loader = new Loader();
loader.load(new URLRequest(image.url));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function loaderComplete(e:Event):void
{
var bm:Bitmap = e.target.content as Bitmap;
// create a VisionImage
var visionImg:VisionImage = Mlkit.createVisionImageFromBitmapData(bm.bitmapData);
trace("visionImg.id = " + visionImg.id);
});
// (Optional) initialize an instance of FaceDetectorOptions
//var options:FaceDetectorOptions = new FaceDetectorOptions();
//options.performanceMod =
//options.minFaceSize =
//options.landmarkMode =
//...
var detector:FaceDetector = Mlkit.initFaceDetector(options);
detector.process(visionImg, null, function ($faces:Vector.<VisionFace>, $error:Error):void
{
if($error) trace($error.message);
if($faces)
{
trace("--------- VisionFace ------");
for(var i:int=0; i < $faces.length; i++)
{
var face:VisionFace = $faces[i];
trace("\t" + face.toString());
}
trace("---------------------------");
}
detector.close();
});
Enjoy building Air apps – With ♥ from MyFlashLabs Team
Introduction to Firebase ANEs collection for Adobe Air apps
Get Started with Firebase Core in AIR
- Prerequisites
- Add Firebase to your app
- Add the Firebase SDK
- Init Firebase Core
- Available ANEs
- Managing Firebase iid
Get Started with Authentication
- Add Authentication
- Init Authentication
- Manage Users
- Phone Number
- Custom Auth
- Anonymous Auth
- State in Email Actions
- Email Link Authentication
Get Started with FCM + OneSignal
- Add FCM ANE
- Init FCM ANE
- Send Your 1st Message
- Send Msg to Topics
- Understanding FCM Messages
- init OneSignal
- Add Firestore
- Init Firestore
- Add Data
- Transactions & Batches
- Delete Data
- Manage the Console
- Get Data
- Get Realtime Updates
- Simple and Compound
- Order and Limit Data
- Paginate Data
- Manage Indexes
- Secure Data
- Offline Data
- Where to Go From Here
Get Started with Realtime Database
- Add Realtime Database
- Init Realtime Database
- Structure Your Database
- Save Data
- Retrieve Data
- Enable Offline Capabilities
Get Started with Remote Config
- Add Storage ANE
- Init Storage ANE
- Upload Files to Storage
- Download Files to Air
- Use File Metadata
- Delete Files