目录

class info
com.huawei.hms.mlsdk.text.MLText.Base
Represents the parent class of text information, which is the basic information about text detected in an image. Five attributes are included:
1. Detected text content
2. Text bounding box
3. Corner points of the text bounding box
4. Confidence of the detection result
5. All detected languages

Public Method Summary

Return typeMethod name
android.graphics.RectgetBorder()
List<? extends MLText.Base>getContents()
StringgetLanguage()
ListgetLanguageList()
FloatgetPossibility()
StringgetStringValue()
android.graphics.Point[]getVertexes()

Public Methods

Method
public android.graphics.Rect getBorder()
Obtains the axis-aligned bounding rectangle of the text.

Return

Typedesc
android.graphics.RectReturns the axis-aligned bounding rectangle of the text.
Method
public List<? extends MLText.Base> getContents()
Obtains the lower-level text object contained in the current text object. The current method needs to be rewritten in the subclass. Text objects are classified into Block, TextLine, and Word. Block is a text object at the highest level, and may include multiple TextLine objects at the lower level. A TextLine object may include multiple Word objects at the lowest level. A Word object is a word that contains a set of characters. If the current text object is the lowest-level text object Word, null is returned.

Return

Typedesc
List<? extends MLText.Base>Returns the lower-level text object contained in the current text object. For example, if the current object is TextLine, a set of Word is returned.
Method
public String getLanguage()
Obtains the language that appears most frequently in the text.

Return

Typedesc
StringReturns the language code.
Supported languages:
en (English), zh (Chinese), ja (Japanese),
ko (Korean), ru (Russian), de (German),
fr (French), it (Italian), pt (Portuguese),
es (Spanish), and rm (Romance languages)
The cloud API also supports the following languages:
pl (Polish), no (Norwegian), sv (Swedish),
da (Danish), tr (Turkish), fi (Finnish),
th (Thai), ar (Arabic), and hi (Hindi)
Method
public List<TextLanguage> getLanguageList()
Obtains the detected languages.

Return

Typedesc
List<TextLanguage>Returns a list of language codes.
Supported languages: en (English),
zh (Chinese), ja (Japanese), ko (Korean),
ru (Russian), de (German), fr (French),
it (Italian), pt (Portuguese), es (Spanish),
and rm (Romance languages)
The cloud API also supports the following languages:
pl (Polish), no (Norwegian), sv (Swedish), da (Danish),
tr (Turkish), fi (Finnish), th (Thai), ar (Arabic),
and hi (Hindi)
Method
public Float getPossibility()
Obtains the confidence of the detection result.

Return

Typedesc
FloatReturns the confidence.
The value range is 0.0–1.0.
A higher confidence indicates a more accurate detection result.
Confidence information is returned only if on-cloud detection is performed.
Method
public String getStringValue()
Obtains the detected text content.

Return

Typedesc
StringReturns the text content.
Method
public android.graphics.Point[] getVertexes()
Obtains the corner points of the text bounding box.

Return

Typedesc
android.graphics.Point[]Returns the corner points of the text bounding box.
The first point in the returned array corresponds to the upper-left
corner point of the text bounding box. Corner points are arranged in the clockwise sequence.