Text.Line

  • Text.Line represents a single line of text.

  • It provides methods to retrieve information about the recognized text, including its angle, bounding box, confidence, corner points, and the actual text string.

  • You can also get a list of the Text.Element objects that compose the line and the prevailing language of the text.

  • Several methods may return null or empty values if no text is found.

public static class Text.Line extends Object

Represents a line of text.

Public Method Summary

float
getAngle ()
Gets the angle(in degrees, clockwise is positive, range is [-180, 180]) of the rotation of the recognized line.
Rect
getBoundingBox ()
Returns the axis-aligned bounding rectangle of the detected text.
float
getConfidence ()
Gets the confidence of the recognized line.
Point[]
getCornerPoints ()
Gets the four corner points in clockwise direction starting with top-left.
synchronized List<Text.Element>
getElements ()
Gets a unmodifiable list of Text.Element s that make up this text line.
String
getRecognizedLanguage ()
Gets prevailing language in the text, if any.
String
getText ()
Gets the recognized text in the Text.Line .

Inherited Method Summary

From class java.lang.Object
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()

Public Methods

public float getAngle ()

Gets the angle(in degrees, clockwise is positive, range is [-180, 180]) of the rotation of the recognized line.

public Rect getBoundingBox ()

Returns the axis-aligned bounding rectangle of the detected text. If nothing found, it returns null.

public float getConfidence ()

Gets the confidence of the recognized line.

It is in range [0.0f, 1.0f].

Note that this information will be unavailable (i.e. returns 0) if you're using the unbundled version of Text Recognition library with an older version of Google Play services (lower than 22.30.XX).

public Point[] getCornerPoints ()

Gets the four corner points in clockwise direction starting with top-left. Due to the possible perspective distortions, this is not necessarily a rectangle. Parts of the region could be outside of the image. If nothing found, it returns null.

public synchronized List<Text.Element> getElements ()

Gets a unmodifiable list of Text.Element s that make up this text line.

Returns an empty list if nothing is found.

public String getRecognizedLanguage ()

Gets prevailing language in the text, if any. The format is in BCP47 (e.g. "en" or "sr-Latn-BA") or "und" if the language could not be determined.

public String getText ()

Gets the recognized text in the Text.Line . It concatenates text strings from underlying Text.Element s separated by white spaces.

The recognized text is in reading order for the language. For Latin, it is left-to-right within a Line.

Returns an empty string if nothing is found.

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

Last updated 2024年10月31日 UTC.