Class TextScript
Writing system selectors for TextRecognizer. The recognizers behind
the portable API are script-specific rather than language-specific: one
script covers every language written in it, and each script model also
recognizes Latin characters embedded in the page.
Each selector call is also a build-time dependency marker, exactly like
VisionBackends. The methods must remain distinct so a build packages
only the script models the application actually asks for; a Japanese OCR
application does not carry the Korean or Devanagari model.
TextRecognizer recognizer = new TextRecognizer(
new VisionOptions().textScript(TextScript.japanese()));
recognizer.process(VisionImage.encoded(jpeg)).ready(result -> {
Log.p(result.getText());
});
A selector states the script, not the backend. Android maps each one to the
matching ML Kit recognizer. Apple platforms map it to the Vision recognition
languages for that script, and report the analysis as unsupported when the
OS does not recognize that script -- selecting
VisionBackends.mlKitTextRecognition() then supplies the script model
through ML Kit instead.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TextScriptchinese()Selects the Chinese script, covering Simplified and Traditional Chinese.static TextScriptSelects the Devanagari script used by Hindi, Marathi, Nepali and Sanskrit.getId()static TextScriptjapanese()Selects the Japanese script, covering kanji, hiragana and katakana.static TextScriptkorean()Selects the Korean script, covering hangul and hanja.static TextScriptlatin()Selects the Latin script, which is also the platform default.toString()Returns a string representation of the object.
-
Method Details
-
latin
Selects the Latin script, which is also the platform default. Referencing it adds no model beyond the one every text recognizer already carries.- Returns:
- the Latin script selector
-
chinese
Selects the Chinese script, covering Simplified and Traditional Chinese.- Returns:
- the Chinese script selector
-
devanagari
Selects the Devanagari script used by Hindi, Marathi, Nepali and Sanskrit.- Returns:
- the Devanagari script selector
-
japanese
Selects the Japanese script, covering kanji, hiragana and katakana.- Returns:
- the Japanese script selector
-
korean
Selects the Korean script, covering hangul and hanja.- Returns:
- the Korean script selector
-
getId
- Returns:
- the stable identifier passed to the port, never
null
-
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-