public final class TextScript
- Object
- 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.
Methods
public static TextScript latin() | Selects the Latin script, which is also the platform default. |
public static TextScript chinese() | Selects the Chinese script, covering Simplified and Traditional Chinese. |
public static TextScript devanagari() | Selects the Devanagari script used by Hindi, Marathi, Nepali and Sanskrit. |
public static TextScript japanese() | Selects the Japanese script, covering kanji, hiragana and katakana. |
public static TextScript korean() | Selects the Korean script, covering hangul and hanja. |
public String getId() | |
public String toString() | Returns a string representation of the object. |
Inherited methods
Method details
latin
public static TextScript latin()Returns
chinese
public static TextScript chinese()Returns
devanagari
public static TextScript devanagari()Returns
japanese
public static TextScript japanese()Returns
korean
public static TextScript korean()Returns
getId
public String getId()Returns
nulltoString
public String toString()