-
Notifications
You must be signed in to change notification settings - Fork 16
M.6 Recognize Landmarks
With ML Kit's landmark recognition API, you can recognize well-known landmarks in an image.
When you pass an image to this API, you get the landmarks that were recognized in it, along with each landmark's geographic coordinates and the region of the image the landmark was found. You can use this information to automatically generate image metadata, create individualized experiences for users based on the content they share, and more.
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 LandmarkDetectorOptions
//var options:LandmarkDetectorOptions = new LandmarkDetectorOptions();
//options.maxResults =
//options.modelType =
//...
var detector:LandmarkDetector = Mlkit.initLandmarkDetector(options);
detector.process(visionImg_landmark,function ($landmarks:Vector.<VisionLandmark>, $error:Error):void
{
if($error) trace($error.message);
if($landmarks)
{
trace("--------- VisionLandmark ------");
for(var i:int=0; i < $landmarks.length; i++)
{
var landmark:VisionLandmark = $landmarks[i];
trace("\t" + landmark.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