Interface ITesseract

All Known Implementing Classes:
Tesseract, Tesseract1

public interface ITesseract
An interface represents common OCR methods.
  • Field Details

  • Method Details

    • doOCR

      String doOCR(File imageFile) throws TesseractException
      Performs OCR operation.
      Parameters:
      imageFile - an image file
      Returns:
      the recognized text
      Throws:
      TesseractException
    • doOCR

      String doOCR(File imageFile, Rectangle rect) throws TesseractException
      Performs OCR operation.
      Parameters:
      imageFile - an image file
      rect - the bounding rectangle defines the region of the image to be recognized. A rectangle of zero dimension or null indicates the whole image.
      Returns:
      the recognized text
      Throws:
      TesseractException
    • doOCR

      Performs OCR operation.
      Parameters:
      bi - a buffered image
      Returns:
      the recognized text
      Throws:
      TesseractException
    • doOCR

      Performs OCR operation.
      Parameters:
      bi - a buffered image
      rect - the bounding rectangle defines the region of the image to be recognized. A rectangle of zero dimension or null indicates the whole image.
      Returns:
      the recognized text
      Throws:
      TesseractException
    • doOCR

      String doOCR(List<IIOImage> imageList, Rectangle rect) throws TesseractException
      Performs OCR operation.
      Parameters:
      imageList - a list of IIOImage objects
      rect - the bounding rectangle defines the region of the image to be recognized. A rectangle of zero dimension or null indicates the whole image.
      Returns:
      the recognized text
      Throws:
      TesseractException
    • doOCR

      String doOCR(List<IIOImage> imageList, String filename, Rectangle rect) throws TesseractException
      Performs OCR operation.
      Parameters:
      imageList - a list of IIOImage objects
      filename - input file name. Needed only for training and reading a UNLV zone file.
      rect - the bounding rectangle defines the region of the image to be recognized. A rectangle of zero dimension or null indicates the whole image.
      Returns:
      the recognized text
      Throws:
      TesseractException
    • doOCR

      String doOCR(int xsize, int ysize, ByteBuffer buf, Rectangle rect, int bpp) throws TesseractException
      Performs OCR operation. Use SetImage, (optionally) SetRectangle, and one or more of the Get*Text functions.
      Parameters:
      xsize - width of image
      ysize - height of image
      buf - pixel data
      rect - the bounding rectangle defines the region of the image to be recognized. A rectangle of zero dimension or null indicates the whole image.
      bpp - bits per pixel, represents the bit depth of the image, with 1 for binary bitmap, 8 for gray, and 24 for color RGB.
      Returns:
      the recognized text
      Throws:
      TesseractException
    • doOCR

      String doOCR(int xsize, int ysize, ByteBuffer buf, String filename, Rectangle rect, int bpp) throws TesseractException
      Performs OCR operation. Use SetImage, (optionally) SetRectangle, and one or more of the Get*Text functions.
      Parameters:
      xsize - width of image
      ysize - height of image
      buf - pixel data
      filename - input file name. Needed only for training and reading a UNLV zone file.
      rect - the bounding rectangle defines the region of the image to be recognized. A rectangle of zero dimension or null indicates the whole image.
      bpp - bits per pixel, represents the bit depth of the image, with 1 for binary bitmap, 8 for gray, and 24 for color RGB.
      Returns:
      the recognized text
      Throws:
      TesseractException
    • setDatapath

      void setDatapath(String datapath)
      Sets tessdata path.
      Parameters:
      datapath - the tessdata path to set
    • setLanguage

      void setLanguage(String language)
      Sets language for OCR.
      Parameters:
      language - the language code, which follows ISO 639-3 standard.
    • setOcrEngineMode

      void setOcrEngineMode(int ocrEngineMode)
      Sets OCR engine mode.
      Parameters:
      ocrEngineMode - the OcrEngineMode to set
    • setPageSegMode

      void setPageSegMode(int mode)
      Sets page segmentation mode.
      Parameters:
      mode - the page segmentation mode to set
    • setTessVariable

      @Deprecated void setTessVariable(String key, String value)
      Sets the value of Tesseract's internal parameter.
      Parameters:
      key - variable name, e.g., tessedit_create_hocr, tessedit_char_whitelist, etc.
      value - value for corresponding variable, e.g., "1", "0", "0123456789", etc.
    • setVariable

      void setVariable(String key, String value)
      Sets the value of Tesseract's internal parameter.
      Parameters:
      key - variable name, e.g., tessedit_create_hocr, tessedit_char_whitelist, etc.
      value - value for corresponding variable, e.g., "1", "0", "0123456789", etc.
    • setConfigs

      void setConfigs(List<String> configs)
      Sets configs to be passed to Tesseract's Init method.
      Parameters:
      configs - list of config filenames, e.g., "digits", "bazaar", "quiet"
    • createDocuments

      void createDocuments(String filename, String outputbase, List<ITesseract.RenderedFormat> formats) throws TesseractException
      Creates documents for given renderers.
      Parameters:
      filename - input image
      outputbase - output filename without extension
      formats - types of renderers
      Throws:
      TesseractException
    • createDocuments

      void createDocuments(String[] filenames, String[] outputbases, List<ITesseract.RenderedFormat> formats) throws TesseractException
      Creates documents for given renderers.
      Parameters:
      filenames - array of input files
      outputbases - array of output filenames without extension
      formats - types of renderers
      Throws:
      TesseractException
    • createDocumentsWithResults

      OCRResult createDocumentsWithResults(BufferedImage bi, String filename, String outputbase, List<ITesseract.RenderedFormat> formats, int pageIteratorLevel) throws TesseractException
      Creates documents with OCR result for given renderers at specified page iterator level.
      Parameters:
      bi - input buffered image
      filename - filename (optional)
      outputbase - output filenames without extension
      formats - types of renderer
      pageIteratorLevel - TessPageIteratorLevel enum
      Returns:
      OCR result
      Throws:
      TesseractException
    • createDocumentsWithResults

      List<OCRResult> createDocumentsWithResults(BufferedImage[] bis, String[] filenames, String[] outputbases, List<ITesseract.RenderedFormat> formats, int pageIteratorLevel) throws TesseractException
      Creates documents with OCR results for given renderers at specified page iterator level.
      Parameters:
      bis - array of input buffered images
      filenames - array of filenames
      outputbases - array of output filenames without extension
      formats - types of renderer
      pageIteratorLevel - TessPageIteratorLevel enum
      Returns:
      list of OCR results
      Throws:
      TesseractException
    • createDocumentsWithResults

      OCRResult createDocumentsWithResults(String filename, String outputbase, List<ITesseract.RenderedFormat> formats, int pageIteratorLevel) throws TesseractException
      Creates documents with OCR result for given renderers at specified page iterator level.
      Parameters:
      filename - input file
      outputbase - output filenames without extension
      formats - types of renderer
      pageIteratorLevel - TessPageIteratorLevel enum
      Returns:
      OCR result
      Throws:
      TesseractException
    • createDocumentsWithResults

      List<OCRResult> createDocumentsWithResults(String[] filenames, String[] outputbases, List<ITesseract.RenderedFormat> formats, int pageIteratorLevel) throws TesseractException
      Creates documents with OCR results for given renderers at specified page iterator level.
      Parameters:
      filenames - array of input files
      outputbases - array of output filenames without extension
      formats - types of renderer
      pageIteratorLevel - TessPageIteratorLevel enum
      Returns:
      list of OCR results
      Throws:
      TesseractException
    • getSegmentedRegions

      List<Rectangle> getSegmentedRegions(BufferedImage bi, int pageIteratorLevel) throws TesseractException
      Gets segmented regions at specified page iterator level.
      Parameters:
      bi - input buffered image
      pageIteratorLevel - TessPageIteratorLevel enum
      Returns:
      list of Rectangle
      Throws:
      TesseractException
    • getWords

      List<Word> getWords(BufferedImage bi, int pageIteratorLevel)
      Gets recognized words at specified page iterator level.
      Parameters:
      bi - input buffered image
      pageIteratorLevel - TessPageIteratorLevel enum
      Returns:
      list of Word