TextRecognizer

TheMobile Vision API is deprecated and no longer maintained.It is now a part ofML Kit which includes all new on-device MLcapabilities. If you use Mobile Vision in your app today, follow themigration guide.
public final classTextRecognizer extends Detector<TextBlock>

Finds and recognizes text in a suppliedFrame.

Build new TextRecognizer instances usingTextRecognizer.Builder.

Recognition results are returned by detect(Frame). The OCR algorithm tries to infer the text layout and organizes each paragraph intoTextBlock instances. If any text is detected, at least oneTextBlock instance will be returned.

Adding the ocr functionalitydependency to your project's AndroidManifest.xml will indicate to the installer that it should download the dependency on application install.

Nested Class Summary

class TextRecognizer.BuilderTextRecognizer Builder. 

Public Method Summary

SparseArray<TextBlock>
detect(Frame frame)
Detects and recognizes text in a image.
boolean
void

Inherited Method Summary

From class com.google.android.gms.vision.Detector
abstractSparseArray<TextBlock>
detect(Frame arg0)
boolean
isOperational()
void
receiveFrame(Frame arg0)
void
release()
boolean
setFocus(int arg0)
void
setProcessor(Processor<TextBlock> arg0)
From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
finalClass<?>
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()

Public Methods

publicSparseArray<TextBlock>detect(Frame frame)

Detects and recognizes text in a image. Only supports bitmap andImageFormat.NV21 for now.

Returns
  • mapping of int toTextBlock, where the int domain represents an opaque ID for the text block.

public booleanisOperational()

public voidrelease()

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2021-06-17 UTC.