Text.Symbol

  • Text.Symbol represents an individual character within a recognized text element in ML Kit's Text Recognition API.

  • It provides access to the symbol's properties such as its text content, bounding box, confidence score, angle, and corner points.

  • The getRecognizedLanguage method can identify the prevailing language of the symbol, while getConfidence indicates the recognition's accuracy.

  • This class is unavailable in older, unbundled versions of the Text Recognition library.

public static class Text.Symbol extends Object

Represents a single symbol in an Text.Element. Note that such field is not available for unbundled versions of Text Recognition library yet.

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 element.
Point[]
getCornerPoints()
Gets the four corner points in clockwise direction starting with top-left.
String
getRecognizedLanguage()
Gets prevailing language in the text, if any.
String
getText()
Gets the recognized text in the Text.Symbol.

Inherited Method Summary

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 element.

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 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.Symbol.

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

Returns an empty string if nothing is found.