Entry point 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(...);
| static TextRecognizer |
getClient()
Gets a new instance of
TextRecognizer
to perform optical character recognition with on-device model.
|
Gets a new instance of TextRecognizer
to perform optical character recognition with on-device model.
To release the resources associated with a TextRecognizer, you need to ensure that
close()
is called on the resulting TextRecognizer
object once it will no longer be used.