-
Notifications
You must be signed in to change notification settings - Fork 16
M.5 Label Images
With ML Kit's image labeling APIs, you can recognize entities in an image without having to provide any additional contextual metadata, using either an on-device API or a cloud-based API.
Image labeling gives you insight into the content of images. When you use the API, you get a list of the entities that were recognized: people, things, places, activities, and so on. Each label found comes with a score that indicates the confidence the ML model has in its relevance. With this information, you can perform tasks such as automatic metadata generation and content moderation.
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 ImageLabelerOptions
//var options:ImageLabelerOptions = new ImageLabelerOptions();
//options.confidenceThreshold =
//...
var detector:ImageLabeler = Mlkit.initImageLabeler(Mlkit.ON_DEVICE, options);
detector.process(visionImg,function ($images:Vector.<VisionImageLabel>, $error:Error):void
{
if($error) trace($error.message);
if($images)
{
trace("--------- VisionImageLabel ------");
for(var i:int=0; i < $images.length; i++)
{
var img:VisionImageLabel = $images[i];
trace("\t" + img.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