FirebaseVisionTextRecognizer

public class FirebaseVisionTextRecognizer extends Object
implements Closeable

Text recognizer for performing optical character recognition(OCR) on an input image.

A text recognizer is created via getOnDeviceTextRecognizer() or getCloudTextRecognizer(). See the code example below.

To use on-device text recognizer:

 FirebaseVisionTextRecognizer textRecognizer =
    FirebaseVision.getInstance().getOnDeviceTextRecognizer();
 
Or use cloud text recognizer:
 FirebaseVisionTextRecognizer textRecognizer =
    FirebaseVision.getInstance().getCloudTextRecognizer();
 
To perform OCR on an image, you first need to create an instance of FirebaseVisionImage from a ByteBuffer, Bitmap, 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 texts in the supplied FirebaseVisionImage.


 Task<FirebaseVisionText> task = textRecognizer.processImage(image);
 task.addOnSuccessListener(...).addOnFailureListener(...);
 

Nested Class Summary

@interface FirebaseVisionTextRecognizer.RecognizerType Recognizer types. 

Constant Summary

int CLOUD Indicates that the recognizer is using a cloud model.
int ON_DEVICE Indicates that the recognizer is using an on-device model.

Public Method Summary

void
close()
Closes the text detector and release its model resources.
int
getRecognizerType()
Gets recognizer type in terms of on-device or cloud.
Task<FirebaseVisionText>

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 recognizer is using a cloud model.

Constant Value: 2

public static final int ON_DEVICE

Indicates that the recognizer is using an on-device model.

Constant Value: 1

Public Methods

public void close ()

Closes the text detector and release its model resources.

Throws

public int getRecognizerType ()

Gets recognizer type in terms of on-device or cloud.

public Task<FirebaseVisionText> processImage (FirebaseVisionImage image)

Detects FirebaseVisionText from a FirebaseVisionImage. The OCR is performed asynchronously. Right now, only the following input types are supported:

For best efficiency, create a FirebaseVisionImage object using one of the following ways:

All other FirebaseVisionImage factory methods will work as well, but possibly slightly slower.
Returns