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

Object
clone()
boolean
equals(Object arg0)
void
finalize()
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()
abstract void
close()
abstract void
close()

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

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

Firebase gives you the tools and infrastructure you need to build better mobile and web apps, improve app quality, and grow your business.

Updated Aug 14, 2020

The Admin SDK lets you interact with Firebase from your server environment to perform actions like generating and verifying Firebase auth tokens, reading and writing to Realtime Database, and so on.

Updated Apr 16, 2024

Firebase gives you the tools and infrastructure you need to build better mobile and web apps, improve app quality, and grow your business.

Updated Oct 18, 2023