FirebaseVisionImageLabeler

public class FirebaseVisionImageLabeler extends Object
implements Closeable

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(...);
 

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
int
getImageLabelerType()
Gets image labeler type.
Task<List<FirebaseVisionImageLabel>>
processImage(FirebaseVisionImage image)
Detects image labels from supplied image.

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.

Constant Value: 2

public static final int ON_DEVICE

Indicates that the labeler is using an on-device base model.

Constant Value: 1

public static final int ON_DEVICE_AUTOML

Indicates that the labeler is using an on-device AutoML model.

Constant Value: 3

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