Package org.sikuli.script
Class OCR
- java.lang.Object
-
- org.sikuli.script.OCR
-
public class OCR extends Object
Static helper class for OCR via Tess4J/Tesseract.The methods in this class are not threadsafe.
- See Also:
- SikuliX docs: Text and OCR
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOCR.OEMOCR Engine modes.static classOCR.Optionsstatic classOCR.PSMPage segmentation modes.
-
Field Summary
Fields Modifier and Type Field Description protected static intPAGE_ITERATOR_LEVEL_LINEINTERNAL: Tesseract option.protected static intPAGE_ITERATOR_LEVEL_WORDINTERNAL: Tesseract option.
-
Constructor Summary
Constructors Constructor Description OCR()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static OCR.OptionsglobalOptions()access/get the current global Options (Singleton).static <SFIRBS> StringreadChar(SFIRBS from)Reads text from the given source (character).static <SFIRBS> StringreadChar(SFIRBS from, OCR.Options options)Reads text from the given source (character).static <SFIRBS> StringreadLine(SFIRBS from)Reads text from the given source (line).static <SFIRBS> StringreadLine(SFIRBS from, OCR.Options options)Reads text from the given source (line).static <SFIRBS> List<Match>readLines(SFIRBS from)Reads text from the given source as lines.static <SFIRBS> List<Match>readLines(SFIRBS from, OCR.Options options)Reads text from the given source as lines.static <SFIRBS> StringreadText(SFIRBS from)Reads text from the given source.static <SFIRBS> StringreadText(SFIRBS from, OCR.Options options)Reads text from the given source.static <SFIRBS> StringreadWord(SFIRBS from)Reads text from the given source (word).static <SFIRBS> StringreadWord(SFIRBS from, OCR.Options options)Reads text from the given source (word).static <SFIRBS> List<Match>readWords(SFIRBS from)Reads text from the given source as words.static <SFIRBS> List<Match>readWords(SFIRBS from, OCR.Options options)Reads text from the given source as words.static OCR.Optionsreset()Resets the global options to the initial defaults.static voidstatus()prints out the current global options.
-
-
-
Field Detail
-
PAGE_ITERATOR_LEVEL_WORD
protected static final int PAGE_ITERATOR_LEVEL_WORD
INTERNAL: Tesseract option.- See Also:
- Constant Field Values
-
PAGE_ITERATOR_LEVEL_LINE
protected static final int PAGE_ITERATOR_LEVEL_LINE
INTERNAL: Tesseract option.- See Also:
- Constant Field Values
-
-
Method Detail
-
globalOptions
public static OCR.Options globalOptions()
access/get the current global Options (Singleton).- Returns:
- the global Options
-
reset
public static OCR.Options reset()
Resets the global options to the initial defaults.- Returns:
- the global Options
- See Also:
OCR.Options.reset()
-
status
public static void status()
prints out the current global options.
-
readText
public static <SFIRBS> String readText(SFIRBS from)
Reads text from the given source.Uses the global options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text from- Returns:
- text
-
readText
public static <SFIRBS> String readText(SFIRBS from, OCR.Options options)
Reads text from the given source.Uses the given options
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text fromoptions- Options to be used- Returns:
- text
-
readLine
public static <SFIRBS> String readLine(SFIRBS from)
Reads text from the given source (line).assuming the source contains a single line of text.
Uses the global options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text from- Returns:
- text
-
readLine
public static <SFIRBS> String readLine(SFIRBS from, OCR.Options options)
Reads text from the given source (line).assuming the source contains a single line of text.
Uses the given options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text fromoptions- options for the used TextRecognizer- Returns:
- text
-
readLines
public static <SFIRBS> List<Match> readLines(SFIRBS from)
Reads text from the given source as lines.Uses the global options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text from- Returns:
- lines as a list of matches
-
readLines
public static <SFIRBS> List<Match> readLines(SFIRBS from, OCR.Options options)
Reads text from the given source as lines.Uses the given options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text fromoptions- options for the used TextRecognizer- Returns:
- lines
-
readWord
public static <SFIRBS> String readWord(SFIRBS from)
Reads text from the given source (word).assuming the source contains a single word of text.
Uses the global options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text from- Returns:
- text
-
readWord
public static <SFIRBS> String readWord(SFIRBS from, OCR.Options options)
Reads text from the given source (word).assuming the source contains a single word of text.
Uses the given options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text fromoptions- options for the used TextRecognizer- Returns:
- text
-
readWords
public static <SFIRBS> List<Match> readWords(SFIRBS from)
Reads text from the given source as words.Uses the global options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text from- Returns:
- words as alist of matches
-
readWords
public static <SFIRBS> List<Match> readWords(SFIRBS from, OCR.Options options)
Reads text from the given source as words.Uses the given options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text fromoptions- options for the used TextRecognizer- Returns:
- words as a list of matches
-
readChar
public static <SFIRBS> String readChar(SFIRBS from)
Reads text from the given source (character).assuming the source contains a single character.
Uses the global options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text from- Returns:
- text
-
readChar
public static <SFIRBS> String readChar(SFIRBS from, OCR.Options options)
Reads text from the given source (character).assuming the source contains a single character.
Uses the given options.
- Type Parameters:
SFIRBS- File name, File, Image, Region, BufferdImage or ScreenImage- Parameters:
from- source to read text fromoptions- options for the used TextRecognizer- Returns:
- text
-
-