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
  • Field Details

  • Constructor Details

    • OCR

      public OCR()
  • Method Details

    • 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 from
      options - 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 from
      options - 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 from
      options - 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 from
      options - 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 from
      options - 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 from
      options - options for the used TextRecognizer
      Returns:
      text