-
-
Notifications
You must be signed in to change notification settings - Fork 5
Vision Landmarks Recognize Landmarks
The contents of this page are based on the original Firebase Documentation
You can use ML Kit to recognize well-known landmarks in an image.
Use of ML Kit to access Cloud ML functionality is subject to the Google Cloud Platform License Agreement and Service Specific Terms, and billed accordingly. For billing information, see the Firebase Pricing page.
- If you have not upgraded your project to a Blaze plan, do so in the Firebase console. Only Blaze-level projects can use the Cloud Vision APIs.
- In the Google Cloud Console, enable the Cloud Vision API:
- Open the Cloud Vision API in the Cloud Console API library.
- Ensure that your Firebase project is selected in the menu at the top of the page.
- If the API is not already enabled, click Enable.
Before you deploy to production an app that uses a Cloud API, you should take some additional steps to prevent and mitigate the effect of unauthorized API access.
By default, the Cloud detector uses the stable version of the model and returns up to 10 results. If you want to change either of these settings, specify them with a CloudDetectorOptions
object as in the following example:
var options:CloudDetectorOptions = new CloudDetectorOptions();
options.modelType = CloudModelType.latest;
options.maxResults = 20;
In the next step, pass the CloudDetectorOptions
object when you create the Cloud detector object.
To recognize landmarks in an image, pass the image as a Bitmapdata to the CloudLandmarkDetector
's detect()
method:
- Get an instance of CloudLandmarkDetector:
var vision:VisionANE = VisionANE.vision;
var cloudDetector: CloudLandmarkDetector = vision.cloudLandmarkDetector(options);
// Or, to use the default settings:
// var cloudDetector = vision.cloudLandmarkDetector();
- Create a VisionImage object using a Bitmapdata.
var visionImage:VisionImage = new VisionImage(bmpLandmarkImage.bitmapData);
- Then, pass the image to the detect() method:
cloudLandmarkDetector.detect(visionImage, function (landmarks:Vector.<CloudLandmark>, error:LandmarkError):void {
if (error) {
// ...
return;
}
// Recognized landmarks
// ...
}
If landmark recognition succeeds, an array of CloudLandmark objects will be passed to the completion handler. From each object, you can get information about a landmark recognized in the image. For example:
for each (var landmark:CloudLandmark in landmarks) {
var landmarkDesc:String = landmark.landmark;
var boundingPoly:Retangle = landmark.frame;
var entityId:String = landmark.entityId;
// A landmark can have multiple locations: for example, the location the image
// was taken, and the location of the landmark depicted.
for each (var location:LatitudeLongitude in landmark.locations) {
var latitude:Number = location.latitude
var longitude:Number = location.longitude
}
var confidence:Number = landmark.confidence
}
Before you deploy to production an app that uses a Cloud API, you should take some additional steps to prevent and mitigate the effect of unauthorized API access.
Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.
Project setup
Analytics
Authentication
Dynamic Links
Google Sign In
Firestore
- Configuring the ANE
- Get Started
- Add and Manage Data
- Query Data
- Get Data
- Get Realtime Updates
- Perform Simple and Compound Queries
- Order and Limit Data
- Paginate Data
Messaging
One Signal
Performance
Remote Config
Storage
- Configuring the ANE
- Get Started
- Create a Reference
- Upload Files
- Download Files
- Use File Metadata
- Delete Files
Crashlytics
Vision
- Detect faces
- Scan barcodes
- Label images
- Recognize landmarks
- Natural Language
- Custom Models
External Links