Used for finding FirebaseVisionImageLabels
in a supplied image.
There are two types of image labeler, one runs inference on device, the other on cloud. On
device image labler is created via
getOnDeviceImageLabeler(FirebaseVisionOnDeviceImageLabelerOptions) or
getOnDeviceImageLabeler() if you wish to use the default options. For example, the
code below creates an on device image labler with default options. Cloud image labler is
created via
getCloudImageLabeler(FirebaseVisionCloudImageLabelerOptions), or
getCloudImageLabeler() if you wish to use the default options. For example, the
code below creates a cloud image labler with default options.
getOnDeviceImageLabeler imageLabeler =
FirebaseVision.getInstance().getOnDeviceImageLabeler();
or
getOnDeviceImageLabeler imageLabeler =
FirebaseVision.getInstance().getCloudImageLabeler();
To perform label detection in an image, you first need to create an instance of
FirebaseVisionImage
from a Bitmap,
ByteBuffer,
etc. See FirebaseVisionImage
documentation for more details. For example, the code below creates a FirebaseVisionImage
from a Bitmap.
FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);Then
the code below can detect labels in the supplied FirebaseVisionImage.
Task<List<FirebaseVisionImageLabel>> task = imageLabeler.processImage(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
| @interface | FirebaseVisionImageLabeler.ImageLabelerType | Image Labeler types. | |
| int | CLOUD | Indicates that the labeler is using a cloud model, meaning that the model inference occurs in the cloud. |
| int | ON_DEVICE | Indicates that the labeler is using an on-device base model. |
| int | ON_DEVICE_AUTOML | Indicates that the labeler is using an on-device AutoML model. |
| void |
close()
|
| int |
getImageLabelerType()
Gets image labeler type.
|
| Task<List<FirebaseVisionImageLabel>> |
Indicates that the labeler is using a cloud model, meaning that the model inference occurs in the cloud.
Indicates that the labeler is using an on-device base model.
Indicates that the labeler is using an on-device AutoML model.
| IOException |
|---|
Gets image labeler type.
Detects image labels from supplied image.
For best efficiency, create a
FirebaseVisionImage object from
fromBitmap(android.graphics.Bitmap). All other
FirebaseVisionImage factory methods will work as well, but possibly slightly
slower.
Task
that asynchronously returns a List of detected
FirebaseVisionImageLabels.