Text
Stay organized with collections
Save and categorize content based on your preferences.
Nested Class Summary
class |
Text.Element
|
Represents a space-separated segment in a line
of text (for example, a word in most Latin languages). |
class |
Text.Line
|
Represents a line of text. |
class |
Text.Symbol
|
Represents a single symbol in an Text.Element . |
class |
Text.TextBlock
|
A block of text (think of it as a paragraph) as
deemed by the OCR engine. |
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
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 String getText ()
Retrieves all the recognized text in the image. It concatenates text strings from
underlying Text.TextBlock
s
separated by '\n'
.
Returns an empty string if nothing is found.
Gets an unmodifiable list of Text.TextBlock
,
which is a block of text and can be further decomposed to a list of Text.Line
.
The recognized text is in reading order for the language. For Latin, this is top to
bottom within a Text.TextBlock
,
and left-to-right within a Text.Line
.
Returns an empty list 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.
[null,null,["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eText\u003c/code\u003e represents a hierarchical structure of recognized text, containing blocks, lines, and elements.\u003c/p\u003e\n"],["\u003cp\u003eIt provides access to the entire recognized text as a single string via \u003ccode\u003egetText()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt allows you to get a list of \u003ccode\u003eTextBlock\u003c/code\u003e objects, representing paragraphs of text, using \u003ccode\u003egetTextBlocks()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eTextBlock\u003c/code\u003e can be further broken down into lines and elements, providing granular access to the text structure.\u003c/p\u003e\n"],["\u003cp\u003eText is organized in reading order based on the detected language.\u003c/p\u003e\n"]]],[],null,["# Text\n\npublic class **Text** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nA hierarchical representation of texts.\n\nA [Text](/android/reference/com/google/mlkit/vision/text/Text) contains a list\nof [Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock),\nand a [Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock)\ncontains a list of [Text.Line](/android/reference/com/google/mlkit/vision/text/Text.Line) which\nis composed of a list of [Text.Element](/android/reference/com/google/mlkit/vision/text/Text.Element). \n\n### Nested Class Summary\n\n|-------|---|---|----------------------------------------------------------------------------------------------------------------|\n| class | [Text.Element](/android/reference/com/google/mlkit/vision/text/Text.Element) || Represents a space-separated segment in a line of text (for example, a word in most Latin languages). |\n| class | [Text.Line](/android/reference/com/google/mlkit/vision/text/Text.Line) || Represents a line of text. |\n| class | [Text.Symbol](/android/reference/com/google/mlkit/vision/text/Text.Symbol) || Represents a single symbol in an [Text.Element](/android/reference/com/google/mlkit/vision/text/Text.Element). |\n| class | [Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock) || A block of text (think of it as a paragraph) as deemed by the OCR engine. |\n\n### Public Method Summary\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [String](//developer.android.com/reference/java/lang/String.html) | [getText](/android/reference/com/google/mlkit/vision/text/Text#getText())() Retrieves all the recognized text in the image. |\n| [List](//developer.android.com/reference/java/util/List.html)\\\u003c[Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock)\\\u003e | [getTextBlocks](/android/reference/com/google/mlkit/vision/text/Text#getTextBlocks())() Gets an unmodifiable list of [Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock), which is a block of text and can be further decomposed to a list of [Text.Line](/android/reference/com/google/mlkit/vision/text/Text.Line). |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public [String](//developer.android.com/reference/java/lang/String.html) **getText** ()\n\nRetrieves all the recognized text in the image. It concatenates text strings from\nunderlying [Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock)s\nseparated by `'\\n'`.\n\nReturns an empty string if nothing is found. \n\n#### public [List](//developer.android.com/reference/java/util/List.html)\\\u003c[Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock)\\\u003e\n**getTextBlocks** ()\n\nGets an unmodifiable list of [Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock),\nwhich is a block of text and can be further decomposed to a list of [Text.Line](/android/reference/com/google/mlkit/vision/text/Text.Line).\n\nThe recognized text is in reading order for the language. For Latin, this is top to\nbottom within a [Text.TextBlock](/android/reference/com/google/mlkit/vision/text/Text.TextBlock),\nand left-to-right within a [Text.Line](/android/reference/com/google/mlkit/vision/text/Text.Line).\n\nReturns an empty list if nothing is found."]]