Used for finding FirebaseVisionImageLabel
s
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();
getOnDeviceImageLabeler imageLabeler =
FirebaseVision.getInstance().getCloudImageLabeler();
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);
FirebaseVisionImage
.
Task
<List<FirebaseVisionImageLabel>> task = imageLabeler.processImage(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
Nested Class Summary
@interface | FirebaseVisionImageLabeler.ImageLabelerType | Image Labeler types. |
Constant Summary
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. |
Public Method Summary
void |
close()
|
int |
getImageLabelerType()
Gets image labeler type.
|
Task<List<FirebaseVisionImageLabel>> |
Inherited Method Summary
Constants
public static final int CLOUD
Indicates that the labeler is using a cloud model, meaning that the model inference occurs in the cloud.
public static final int ON_DEVICE
Indicates that the labeler is using an on-device base model.
public static final int ON_DEVICE_AUTOML
Indicates that the labeler is using an on-device AutoML model.
Public Methods
public void close ()
Throws
IOException |
---|
public int getImageLabelerType ()
Gets image labeler type.
public Task<List<FirebaseVisionImageLabel>> processImage (FirebaseVisionImage image)
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.
Returns
- A
Task
that asynchronously returns aList
of detectedFirebaseVisionImageLabel
s.