TextRecognition
client for performing optical character recognition(OCR) on an input image to detect
latin-based characters.
A TextRecognizer
is created via getClient().
See the code example below.
TextRecognizer textRecognizer = TextRecognition.getClient();
To perform OCR on an image, you first need to create an instance of InputImage from a
ByteBuffer,
Bitmap,
etc. See InputImage
documentation for more details. For example, the code below creates an InputImage from a
Bitmap.
InputImage image = InputImage.fromBitmap(bitmap);
Then the code below can detect texts in the supplied InputImage.
Task<Text> task = textRecognizer.process(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
| abstract void |
close()
Closes the detector and releases its resources.
|
| abstract Task<Text> |
Closes the detector and releases its resources.
Detects latin-based characters from the supplied image.
Create an InputImage
object using one of InputImage's
factory methods. See InputImage
documentation for more details.
If the text recognition model has not been downloaded yet, the returned
Task will
contain an MlKitException
with error code UNAVAILABLE.