Class TessBaseAPI

  • All Implemented Interfaces:
    AutoCloseable

    @Namespace("tesseract")
    @NoOffset
    @Properties(inherit=tesseract.class)
    public class TessBaseAPI
    extends Pointer
    Base class for all tesseract APIs. Specific classes can add ability to work on different inputs or produce different outputs. This class is mostly an interface layer on top of the Tesseract instance class to hide the data types so that users of this class don't have to include any other Tesseract headers.
    • Constructor Detail

      • TessBaseAPI

        public TessBaseAPI()
    • Method Detail

      • Version

        @Cast("const char*")
        public static BytePointer Version()
        Returns the version identifier as a static string. Do not delete.
      • SetInputName

        public void SetInputName​(@Cast("const char*")
                                 BytePointer name)
        Set the name of the input file. Needed for training and reading a UNLV zone file, and for searchable PDF output.
      • SetInputName

        public void SetInputName​(String name)
      • GetInputName

        @Cast("const char*")
        public BytePointer GetInputName()
        These functions are required for searchable PDF output. We need our hands on the input file so that we can include it in the PDF without transcoding. If that is not possible, we need the original image. Finally, resolution metadata is stored in the PDF so we need that as well.
      • SetInputImage

        public void SetInputImage​(org.bytedeco.leptonica.PIX pix)
      • GetInputImage

        public org.bytedeco.leptonica.PIX GetInputImage()
      • GetSourceYResolution

        public int GetSourceYResolution()
      • SetOutputName

        public void SetOutputName​(@Cast("const char*")
                                  BytePointer name)
        Set the name of the bonus output files. Needed only for debugging.
      • SetOutputName

        public void SetOutputName​(String name)
      • SetVariable

        @Cast("bool")
        public boolean SetVariable​(@Cast("const char*")
                                   BytePointer name,
                                   @Cast("const char*")
                                   BytePointer value)
        Set the value of an internal "parameter." Supply the name of the parameter and the value as a string, just as you would in a config file. Returns false if the name lookup failed. Eg SetVariable("tessedit_char_blacklist", "xyz"); to ignore x, y and z. Or SetVariable("classify_bln_numeric_mode", "1"); to set numeric-only mode. SetVariable may be used before Init, but settings will revert to defaults on End(). Note: Must be called after Init(). Only works for non-init variables (init variables should be passed to Init()).
      • SetVariable

        @Cast("bool")
        public boolean SetVariable​(String name,
                                   String value)
      • SetDebugVariable

        @Cast("bool")
        public boolean SetDebugVariable​(String name,
                                        String value)
      • GetIntVariable

        @Cast("bool")
        public boolean GetIntVariable​(@Cast("const char*")
                                      BytePointer name,
                                      IntPointer value)
        Returns true if the parameter was found among Tesseract parameters. Fills in value with the value of the parameter.
      • GetIntVariable

        @Cast("bool")
        public boolean GetIntVariable​(@Cast("const char*")
                                      BytePointer name,
                                      int[] value)
      • GetIntVariable

        @Cast("bool")
        public boolean GetIntVariable​(String name,
                                      int[] value)
      • GetBoolVariable

        @Cast("bool")
        public boolean GetBoolVariable​(String name,
                                       @Cast("bool*")
                                       boolean[] value)
      • GetDoubleVariable

        @Cast("bool")
        public boolean GetDoubleVariable​(@Cast("const char*")
                                         BytePointer name,
                                         double[] value)
      • GetDoubleVariable

        @Cast("bool")
        public boolean GetDoubleVariable​(String name,
                                         double[] value)
      • GetStringVariable

        @Cast("const char*")
        public BytePointer GetStringVariable​(@Cast("const char*")
                                             BytePointer name)
        Returns the pointer to the string that represents the value of the parameter if it was found among Tesseract parameters.
      • GetStringVariable

        public String GetStringVariable​(String name)
      • PrintFontsTable

        public void PrintFontsTable​(@Cast("FILE*")
                                    Pointer fp)
        Print Tesseract fonts table to the given file.
      • PrintVariables

        public void PrintVariables​(@Cast("FILE*")
                                   Pointer fp)
        Print Tesseract parameters to the given file.
      • Init

        public int Init​(@Cast("const char*")
                        BytePointer datapath,
                        @Cast("const char*")
                        BytePointer language,
                        @Cast("tesseract::OcrEngineMode")
                        int mode,
                        @Cast("char**")
                        PointerPointer configs,
                        int configs_size,
                        @Const
                        StringVector vars_vec,
                        @Const
                        StringVector vars_values,
                        @Cast("bool")
                        boolean set_only_non_debug_params)
        Instances are now mostly thread-safe and totally independent, but some global parameters remain. Basically it is safe to use multiple TessBaseAPIs in different threads in parallel, UNLESS: you use SetVariable on some of the Params in classify and textord. If you do, then the effect will be to change it for all your instances. Start tesseract. Returns zero on success and -1 on failure. NOTE that the only members that may be called before Init are those listed above here in the class definition. The datapath must be the name of the tessdata directory. The language is (usually) an ISO 639-3 string or nullptr will default to eng. It is entirely safe (and eventually will be efficient too) to call Init multiple times on the same instance to change language, or just to reset the classifier. The language may be a string of the form [~][+[~]]* indicating that multiple languages are to be loaded. Eg hin+eng will load Hindi and English. Languages may specify internally that they want to be loaded with one or more other languages, so the ~ sign is available to override that. Eg if hin were set to load eng by default, then hin+~eng would force loading only hin. The number of loaded languages is limited only by memory, with the caveat that loading additional languages will impact both speed and accuracy, as there is more work to do to decide on the applicable language, and there is more chance of hallucinating incorrect words. WARNING: On changing languages, all Tesseract parameters are reset back to their default values. (Which may vary between languages.) If you have a rare need to set a Variable that controls initialization for a second call to Init you should explicitly call End() and then use SetVariable before Init. This is only a very rare use case, since there are very few uses that require any parameters to be set before Init. If set_only_non_debug_params is true, only params that do not contain "debug" in the name will be set.
      • Init

        public int Init​(String datapath,
                        String language,
                        @Cast("tesseract::OcrEngineMode")
                        int oem)
      • Init

        public int Init​(String datapath,
                        String language)
      • GetInitLanguagesAsString

        @Cast("const char*")
        public BytePointer GetInitLanguagesAsString()
        Returns the languages string used in the last valid initialization. If the last initialization specified "deu+hin" then that will be returned. If hin loaded eng automatically as well, then that will not be included in this list. To find the languages actually loaded use GetLoadedLanguagesAsVector. The returned string should NOT be deleted.
      • GetLoadedLanguagesAsVector

        public void GetLoadedLanguagesAsVector​(StringVector langs)
        Returns the loaded languages in the vector of std::string. Includes all languages loaded by the last Init, including those loaded as dependencies of other loaded languages.
      • GetAvailableLanguagesAsVector

        public void GetAvailableLanguagesAsVector​(StringVector langs)
        Returns the available languages in the sorted vector of std::string.
      • InitForAnalysePage

        public void InitForAnalysePage()
        Init only for page layout analysis. Use only for calls to SetImage and AnalysePage. Calls that attempt recognition will generate an error.
      • ReadConfigFile

        public void ReadConfigFile​(@Cast("const char*")
                                   BytePointer filename)
        Read a "config" file containing a set of param, value pairs. Searches the standard places: tessdata/configs, tessdata/tessconfigs and also accepts a relative or absolute path name. Note: only non-init params will be set (init params are set by Init()).
      • ReadConfigFile

        public void ReadConfigFile​(String filename)
      • ReadDebugConfigFile

        public void ReadDebugConfigFile​(@Cast("const char*")
                                        BytePointer filename)
        Same as above, but only set debug params from the given config file.
      • ReadDebugConfigFile

        public void ReadDebugConfigFile​(String filename)
      • SetPageSegMode

        public void SetPageSegMode​(@Cast("tesseract::PageSegMode")
                                   int mode)
        Set the current page segmentation mode. Defaults to PSM_SINGLE_BLOCK. The mode is stored as an IntParam so it can also be modified by ReadConfigFile or SetVariable("tessedit_pageseg_mode", mode as string).
      • GetPageSegMode

        @Cast("tesseract::PageSegMode")
        public int GetPageSegMode()
        Return the current page segmentation mode.
      • TesseractRect

        @Cast("char*")
        public BytePointer TesseractRect​(@Cast("const unsigned char*")
                                         BytePointer imagedata,
                                         int bytes_per_pixel,
                                         int bytes_per_line,
                                         int left,
                                         int top,
                                         int width,
                                         int height)
        Recognize a rectangle from an image and return the result as a string. May be called many times for a single Init. Currently has no error checking. Greyscale of 8 and color of 24 or 32 bits per pixel may be given. Palette color images will not work properly and must be converted to 24 bit. Binary images of 1 bit per pixel may also be given but they must be byte packed with the MSB of the first byte being the first pixel, and a 1 represents WHITE. For binary images set bytes_per_pixel=0. The recognized text is returned as a char* which is coded as UTF8 and must be freed with the delete [] operator. Note that TesseractRect is the simplified convenience interface. For advanced uses, use SetImage, (optionally) SetRectangle, Recognize, and one or more of the Get*Text functions below.
      • TesseractRect

        @Cast("char*")
        public ByteBuffer TesseractRect​(@Cast("const unsigned char*")
                                        ByteBuffer imagedata,
                                        int bytes_per_pixel,
                                        int bytes_per_line,
                                        int left,
                                        int top,
                                        int width,
                                        int height)
      • TesseractRect

        @Cast("char*")
        public byte[] TesseractRect​(@Cast("const unsigned char*")
                                    byte[] imagedata,
                                    int bytes_per_pixel,
                                    int bytes_per_line,
                                    int left,
                                    int top,
                                    int width,
                                    int height)
      • ClearAdaptiveClassifier

        public void ClearAdaptiveClassifier()
        Call between pages or documents etc to free up memory and forget adaptive data.
      • SetImage

        public void SetImage​(@Cast("const unsigned char*")
                             BytePointer imagedata,
                             int width,
                             int height,
                             int bytes_per_pixel,
                             int bytes_per_line)
        Provide an image for Tesseract to recognize. Format is as TesseractRect above. Copies the image buffer and converts to Pix. SetImage clears all recognition results, and sets the rectangle to the full image, so it may be followed immediately by a GetUTF8Text, and it will automatically perform recognition.
      • SetImage

        public void SetImage​(@Cast("const unsigned char*")
                             ByteBuffer imagedata,
                             int width,
                             int height,
                             int bytes_per_pixel,
                             int bytes_per_line)
      • SetImage

        public void SetImage​(@Cast("const unsigned char*")
                             byte[] imagedata,
                             int width,
                             int height,
                             int bytes_per_pixel,
                             int bytes_per_line)
      • SetImage

        public void SetImage​(org.bytedeco.leptonica.PIX pix)
        Provide an image for Tesseract to recognize. As with SetImage above, Tesseract takes its own copy of the image, so it need not persist until after Recognize. Pix vs raw, which to use? Use Pix where possible. Tesseract uses Pix as its internal representation and it is therefore more efficient to provide a Pix directly.
      • SetSourceResolution

        public void SetSourceResolution​(int ppi)
        Set the resolution of the source image in pixels per inch so font size information can be calculated in results. Call this after SetImage().
      • SetRectangle

        public void SetRectangle​(int left,
                                 int top,
                                 int width,
                                 int height)
        Restrict recognition to a sub-rectangle of the image. Call after SetImage. Each SetRectangle clears the recogntion results so multiple rectangles can be recognized with the same image.
      • GetThresholdedImage

        public org.bytedeco.leptonica.PIX GetThresholdedImage()
        Get a copy of the internal thresholded image from Tesseract. Caller takes ownership of the Pix and must pixDestroy it. May be called any time after SetImage, or after TesseractRect.
      • GetGradient

        public float GetGradient()
        Return average gradient of lines on page.
      • GetRegions

        public org.bytedeco.leptonica.BOXA GetRegions​(@Cast("Pixa**")
                                                      PointerPointer pixa)
        Get the result of page layout analysis as a leptonica-style Boxa, Pixa pair, in reading order. Can be called before or after Recognize.
      • GetRegions

        public org.bytedeco.leptonica.BOXA GetRegions​(@ByPtrPtr
                                                      org.bytedeco.leptonica.PIXA pixa)
      • GetTextlines

        public org.bytedeco.leptonica.BOXA GetTextlines​(@Cast("bool")
                                                        boolean raw_image,
                                                        int raw_padding,
                                                        @Cast("Pixa**")
                                                        PointerPointer pixa,
                                                        @Cast("int**")
                                                        PointerPointer blockids,
                                                        @Cast("int**")
                                                        PointerPointer paraids)
        Get the textlines as a leptonica-style Boxa, Pixa pair, in reading order. Can be called before or after Recognize. If raw_image is true, then extract from the original image instead of the thresholded image and pad by raw_padding pixels. If blockids is not nullptr, the block-id of each line is also returned as an array of one element per line. delete [] after use. If paraids is not nullptr, the paragraph-id of each line within its block is also returned as an array of one element per line. delete [] after use.
      • GetTextlines

        public org.bytedeco.leptonica.BOXA GetTextlines​(@Cast("bool")
                                                        boolean raw_image,
                                                        int raw_padding,
                                                        @ByPtrPtr
                                                        org.bytedeco.leptonica.PIXA pixa,
                                                        @ByPtrPtr
                                                        int[] blockids,
                                                        @ByPtrPtr
                                                        int[] paraids)
      • GetTextlines

        public org.bytedeco.leptonica.BOXA GetTextlines​(@ByPtrPtr
                                                        org.bytedeco.leptonica.PIXA pixa,
                                                        @ByPtrPtr
                                                        IntPointer blockids)
      • GetTextlines

        public org.bytedeco.leptonica.BOXA GetTextlines​(@ByPtrPtr
                                                        org.bytedeco.leptonica.PIXA pixa,
                                                        @ByPtrPtr
                                                        IntBuffer blockids)
      • GetTextlines

        public org.bytedeco.leptonica.BOXA GetTextlines​(@ByPtrPtr
                                                        org.bytedeco.leptonica.PIXA pixa,
                                                        @ByPtrPtr
                                                        int[] blockids)
      • GetStrips

        public org.bytedeco.leptonica.BOXA GetStrips​(@Cast("Pixa**")
                                                     PointerPointer pixa,
                                                     @Cast("int**")
                                                     PointerPointer blockids)
        Get textlines and strips of image regions as a leptonica-style Boxa, Pixa pair, in reading order. Enables downstream handling of non-rectangular regions. Can be called before or after Recognize. If blockids is not nullptr, the block-id of each line is also returned as an array of one element per line. delete [] after use.
      • GetStrips

        public org.bytedeco.leptonica.BOXA GetStrips​(@ByPtrPtr
                                                     org.bytedeco.leptonica.PIXA pixa,
                                                     @ByPtrPtr
                                                     IntBuffer blockids)
      • GetStrips

        public org.bytedeco.leptonica.BOXA GetStrips​(@ByPtrPtr
                                                     org.bytedeco.leptonica.PIXA pixa,
                                                     @ByPtrPtr
                                                     int[] blockids)
      • GetWords

        public org.bytedeco.leptonica.BOXA GetWords​(@Cast("Pixa**")
                                                    PointerPointer pixa)
        Get the words as a leptonica-style Boxa, Pixa pair, in reading order. Can be called before or after Recognize.
      • GetWords

        public org.bytedeco.leptonica.BOXA GetWords​(@ByPtrPtr
                                                    org.bytedeco.leptonica.PIXA pixa)
      • GetConnectedComponents

        public org.bytedeco.leptonica.BOXA GetConnectedComponents​(@Cast("Pixa**")
                                                                  PointerPointer cc)
        Gets the individual connected (text) components (created after pages segmentation step, but before recognition) as a leptonica-style Boxa, Pixa pair, in reading order. Can be called before or after Recognize. Note: the caller is responsible for calling boxaDestroy() on the returned Boxa array and pixaDestroy() on cc array.
      • GetConnectedComponents

        public org.bytedeco.leptonica.BOXA GetConnectedComponents​(@ByPtrPtr
                                                                  org.bytedeco.leptonica.PIXA cc)
      • GetComponentImages

        public org.bytedeco.leptonica.BOXA GetComponentImages​(@Cast("tesseract::PageIteratorLevel")
                                                              int level,
                                                              @Cast("bool")
                                                              boolean text_only,
                                                              @Cast("bool")
                                                              boolean raw_image,
                                                              int raw_padding,
                                                              @Cast("Pixa**")
                                                              PointerPointer pixa,
                                                              @Cast("int**")
                                                              PointerPointer blockids,
                                                              @Cast("int**")
                                                              PointerPointer paraids)
        Get the given level kind of components (block, textline, word etc.) as a leptonica-style Boxa, Pixa pair, in reading order. Can be called before or after Recognize. If blockids is not nullptr, the block-id of each component is also returned as an array of one element per component. delete [] after use. If blockids is not nullptr, the paragraph-id of each component with its block is also returned as an array of one element per component. delete [] after use. If raw_image is true, then portions of the original image are extracted instead of the thresholded image and padded with raw_padding. If text_only is true, then only text components are returned.
      • GetComponentImages

        public org.bytedeco.leptonica.BOXA GetComponentImages​(@Cast("tesseract::PageIteratorLevel")
                                                              int level,
                                                              @Cast("bool")
                                                              boolean text_only,
                                                              @Cast("bool")
                                                              boolean raw_image,
                                                              int raw_padding,
                                                              @ByPtrPtr
                                                              org.bytedeco.leptonica.PIXA pixa,
                                                              @ByPtrPtr
                                                              IntPointer blockids,
                                                              @ByPtrPtr
                                                              IntPointer paraids)
      • GetComponentImages

        public org.bytedeco.leptonica.BOXA GetComponentImages​(@Cast("tesseract::PageIteratorLevel")
                                                              int level,
                                                              @Cast("bool")
                                                              boolean text_only,
                                                              @Cast("bool")
                                                              boolean raw_image,
                                                              int raw_padding,
                                                              @ByPtrPtr
                                                              org.bytedeco.leptonica.PIXA pixa,
                                                              @ByPtrPtr
                                                              IntBuffer blockids,
                                                              @ByPtrPtr
                                                              IntBuffer paraids)
      • GetComponentImages

        public org.bytedeco.leptonica.BOXA GetComponentImages​(@Cast("tesseract::PageIteratorLevel")
                                                              int level,
                                                              @Cast("bool")
                                                              boolean text_only,
                                                              @Cast("bool")
                                                              boolean raw_image,
                                                              int raw_padding,
                                                              @ByPtrPtr
                                                              org.bytedeco.leptonica.PIXA pixa,
                                                              @ByPtrPtr
                                                              int[] blockids,
                                                              @ByPtrPtr
                                                              int[] paraids)
      • GetComponentImages

        public org.bytedeco.leptonica.BOXA GetComponentImages​(@Cast("const tesseract::PageIteratorLevel")
                                                              int level,
                                                              @Cast("const bool")
                                                              boolean text_only,
                                                              @Cast("Pixa**")
                                                              PointerPointer pixa,
                                                              @Cast("int**")
                                                              PointerPointer blockids)
      • GetComponentImages

        public org.bytedeco.leptonica.BOXA GetComponentImages​(@Cast("const tesseract::PageIteratorLevel")
                                                              int level,
                                                              @Cast("const bool")
                                                              boolean text_only,
                                                              @ByPtrPtr
                                                              org.bytedeco.leptonica.PIXA pixa,
                                                              @ByPtrPtr
                                                              IntPointer blockids)
      • GetComponentImages

        public org.bytedeco.leptonica.BOXA GetComponentImages​(@Cast("const tesseract::PageIteratorLevel")
                                                              int level,
                                                              @Cast("const bool")
                                                              boolean text_only,
                                                              @ByPtrPtr
                                                              org.bytedeco.leptonica.PIXA pixa,
                                                              @ByPtrPtr
                                                              IntBuffer blockids)
      • GetComponentImages

        public org.bytedeco.leptonica.BOXA GetComponentImages​(@Cast("const tesseract::PageIteratorLevel")
                                                              int level,
                                                              @Cast("const bool")
                                                              boolean text_only,
                                                              @ByPtrPtr
                                                              org.bytedeco.leptonica.PIXA pixa,
                                                              @ByPtrPtr
                                                              int[] blockids)
      • GetThresholdedImageScaleFactor

        public int GetThresholdedImageScaleFactor()
        Returns the scale factor of the thresholded image that would be returned by GetThresholdedImage() and the various GetX() methods that call GetComponentImages(). Returns 0 if no thresholder has been set.
      • AnalyseLayout

        public PageIterator AnalyseLayout()
        Runs page layout analysis in the mode set by SetPageSegMode. May optionally be called prior to Recognize to get access to just the page layout results. Returns an iterator to the results. If merge_similar_words is true, words are combined where suitable for use with a line recognizer. Use if you want to use AnalyseLayout to find the textlines, and then want to process textline fragments with an external line recognizer. Returns nullptr on error or an empty page. The returned iterator must be deleted after use. WARNING! This class points to data held within the TessBaseAPI class, and therefore can only be used while the TessBaseAPI class still exists and has not been subjected to a call of Init, SetImage, Recognize, Clear, End DetectOS, or anything else that changes the internal PAGE_RES.
      • AnalyseLayout

        public PageIterator AnalyseLayout​(@Cast("bool")
                                          boolean merge_similar_words)
      • Recognize

        public int Recognize​(ETEXT_DESC monitor)
        Recognize the image from SetAndThresholdImage, generating Tesseract internal structures. Returns 0 on success. Optional. The Get*Text functions below will call Recognize if needed. After Recognize, the output is kept internally until the next SetImage.
      • ProcessPages

        @Cast("bool")
        public boolean ProcessPages​(@Cast("const char*")
                                    BytePointer filename,
                                    @Cast("const char*")
                                    BytePointer retry_config,
                                    int timeout_millisec,
                                    TessResultRenderer renderer)
        Turns images into symbolic text. filename can point to a single image, a multi-page TIFF, or a plain text list of image filenames. retry_config is useful for debugging. If not nullptr, you can fall back to an alternate configuration if a page fails for some reason. timeout_millisec terminates processing if any single page takes too long. Set to 0 for unlimited time. renderer is responsible for creating the output. For example, use the TessTextRenderer if you want plaintext output, or the TessPDFRender to produce searchable PDF. If tessedit_page_number is non-negative, will only process that single page. Works for multi-page tiff file, or filelist. Returns true if successful, false on error.
      • ProcessPage

        @Cast("bool")
        public boolean ProcessPage​(org.bytedeco.leptonica.PIX pix,
                                   int page_index,
                                   @Cast("const char*")
                                   BytePointer filename,
                                   @Cast("const char*")
                                   BytePointer retry_config,
                                   int timeout_millisec,
                                   TessResultRenderer renderer)
        Turn a single image into symbolic text. The pix is the image processed. filename and page_index are metadata used by side-effect processes, such as reading a box file or formatting as hOCR. See ProcessPages for descriptions of other parameters.
      • ProcessPage

        @Cast("bool")
        public boolean ProcessPage​(org.bytedeco.leptonica.PIX pix,
                                   int page_index,
                                   String filename,
                                   String retry_config,
                                   int timeout_millisec,
                                   TessResultRenderer renderer)
      • GetIterator

        public ResultIterator GetIterator()
        Get a reading-order iterator to the results of LayoutAnalysis and/or Recognize. The returned iterator must be deleted after use. WARNING! This class points to data held within the TessBaseAPI class, and therefore can only be used while the TessBaseAPI class still exists and has not been subjected to a call of Init, SetImage, Recognize, Clear, End DetectOS, or anything else that changes the internal PAGE_RES.
      • GetMutableIterator

        public MutableIterator GetMutableIterator()
        Get a mutable iterator to the results of LayoutAnalysis and/or Recognize. The returned iterator must be deleted after use. WARNING! This class points to data held within the TessBaseAPI class, and therefore can only be used while the TessBaseAPI class still exists and has not been subjected to a call of Init, SetImage, Recognize, Clear, End DetectOS, or anything else that changes the internal PAGE_RES.
      • GetUTF8Text

        @Cast("char*")
        public BytePointer GetUTF8Text()
        The recognized text is returned as a char* which is coded as UTF8 and must be freed with the delete [] operator.
      • GetHOCRText

        @Cast("char*")
        public BytePointer GetHOCRText​(ETEXT_DESC monitor,
                                       int page_number)
        Make a HTML-formatted string with hOCR markup from the internal data structures. page_number is 0-based but will appear in the output as 1-based. monitor can be used to cancel the recognition receive progress callbacks Returned string must be freed with the delete [] operator.
      • GetHOCRText

        @Cast("char*")
        public BytePointer GetHOCRText​(int page_number)
        Make a HTML-formatted string with hOCR markup from the internal data structures. page_number is 0-based but will appear in the output as 1-based. Returned string must be freed with the delete [] operator.
      • GetAltoText

        @Cast("char*")
        public BytePointer GetAltoText​(ETEXT_DESC monitor,
                                       int page_number)
        Make an XML-formatted string with Alto markup from the internal data structures.
      • GetAltoText

        @Cast("char*")
        public BytePointer GetAltoText​(int page_number)
        Make an XML-formatted string with Alto markup from the internal data structures.
      • GetPAGEText

        @Cast("char*")
        public BytePointer GetPAGEText​(ETEXT_DESC monitor,
                                       int page_number)
        Make an XML-formatted string with PAGE markup from the internal data structures.
      • GetPAGEText

        @Cast("char*")
        public BytePointer GetPAGEText​(int page_number)
        Make an XML-formatted string with PAGE markup from the internal data structures.
      • GetTSVText

        @Cast("char*")
        public BytePointer GetTSVText​(int page_number)
        Make a TSV-formatted string from the internal data structures. page_number is 0-based but will appear in the output as 1-based. Returned string must be freed with the delete [] operator.
      • GetLSTMBoxText

        @Cast("char*")
        public BytePointer GetLSTMBoxText​(int page_number)
        Make a box file for LSTM training from the internal data structures. Constructs coordinates in the original image - not just the rectangle. page_number is a 0-based page index that will appear in the box file. Returned string must be freed with the delete [] operator.
      • GetBoxText

        @Cast("char*")
        public BytePointer GetBoxText​(int page_number)
        The recognized text is returned as a char* which is coded in the same format as a box file used in training. Constructs coordinates in the original image - not just the rectangle. page_number is a 0-based page index that will appear in the box file. Returned string must be freed with the delete [] operator.
      • GetWordStrBoxText

        @Cast("char*")
        public BytePointer GetWordStrBoxText​(int page_number)
        The recognized text is returned as a char* which is coded in the same format as a WordStr box file used in training. page_number is a 0-based page index that will appear in the box file. Returned string must be freed with the delete [] operator.
      • GetUNLVText

        @Cast("char*")
        public BytePointer GetUNLVText()
        The recognized text is returned as a char* which is coded as UNLV format Latin-1 with specific reject and suspect codes. Returned string must be freed with the delete [] operator.
      • DetectOrientationScript

        @Cast("bool")
        public boolean DetectOrientationScript​(IntPointer orient_deg,
                                               FloatPointer orient_conf,
                                               @Cast("const char**")
                                               PointerPointer script_name,
                                               FloatPointer script_conf)
        Detect the orientation of the input image and apparent script (alphabet). orient_deg is the detected clockwise rotation of the input image in degrees (0, 90, 180, 270) orient_conf is the confidence (15.0 is reasonably confident) script_name is an ASCII string, the name of the script, e.g. "Latin" script_conf is confidence level in the script Returns true on success and writes values to each parameter as an output
      • DetectOrientationScript

        @Cast("bool")
        public boolean DetectOrientationScript​(int[] orient_deg,
                                               float[] orient_conf,
                                               @Cast("const char**") @ByPtrPtr
                                               byte[] script_name,
                                               float[] script_conf)
      • GetOsdText

        @Cast("char*")
        public BytePointer GetOsdText​(int page_number)
        The recognized text is returned as a char* which is coded as UTF8 and must be freed with the delete [] operator. page_number is a 0-based page index that will appear in the osd file.
      • MeanTextConf

        public int MeanTextConf()
        Returns the (average) confidence value between 0 and 100.
      • AllWordConfidences

        public IntPointer AllWordConfidences()
        Returns all word confidences (between 0 and 100) in an array, terminated by -1. The calling function must delete [] after use. The number of confidences should correspond to the number of space- delimited words in GetUTF8Text.
      • AdaptToWordStr

        @Cast("bool")
        public boolean AdaptToWordStr​(@Cast("tesseract::PageSegMode")
                                      int mode,
                                      @Cast("const char*")
                                      BytePointer wordstr)
        Applies the given word to the adaptive classifier if possible. The word must be SPACE-DELIMITED UTF-8 - l i k e t h i s , so it can tell the boundaries of the graphemes. Assumes that SetImage/SetRectangle have been used to set the image to the given word. The mode arg should be PSM_SINGLE_WORD or PSM_CIRCLE_WORD, as that will be used to control layout analysis. The currently set PageSegMode is preserved. Returns false if adaption was not possible for some reason.
      • AdaptToWordStr

        @Cast("bool")
        public boolean AdaptToWordStr​(@Cast("tesseract::PageSegMode")
                                      int mode,
                                      String wordstr)
      • Clear

        public void Clear()
        Free up recognition results and any stored image data, without actually freeing any recognition data that would be time-consuming to reload. Afterwards, you must call SetImage or TesseractRect before doing any Recognize or Get* operation.
      • End

        public void End()
        Close down tesseract and free up all memory. End() is equivalent to destructing and reconstructing your TessBaseAPI. Once End() has been used, none of the other API functions may be used other than Init and anything declared above it in the class definition.
      • ClearPersistentCache

        public static void ClearPersistentCache()
        Clear any library-level memory caches. There are a variety of expensive-to-load constant data structures (mostly language dictionaries) that are cached globally -- surviving the Init() and End() of individual TessBaseAPI's. This function allows the clearing of these caches.
      • IsValidWord

        public int IsValidWord​(@Cast("const char*")
                               BytePointer word)
        Check whether a word is valid according to Tesseract's language model
        Returns:
        0 if the word is invalid, non-zero if valid. \warning temporary! This function will be removed from here and placed in a separate API at some future time.
      • IsValidWord

        public int IsValidWord​(String word)
      • IsValidCharacter

        @Cast("bool")
        public boolean IsValidCharacter​(@Cast("const char*")
                                        BytePointer utf8_character)
      • IsValidCharacter

        @Cast("bool")
        public boolean IsValidCharacter​(String utf8_character)
      • GetTextDirection

        @Cast("bool")
        public boolean GetTextDirection​(int[] out_offset,
                                        float[] out_slope)
      • SetDictFunc

        public void SetDictFunc​(DictFunc f)
        Sets Dict::letter_is_okay_ function to point to the given function.
      • SetProbabilityInContextFunc

        public void SetProbabilityInContextFunc​(ProbabilityInContextFunc f)
        Sets Dict::probability_in_context_ function to point to the given function.
      • DetectOS

        @Cast("bool")
        public boolean DetectOS​(OSResults arg0)
        Estimates the Orientation And Script of the image.
        Returns:
        true if the image was processed successfully.
      • GetBlockTextOrientations

        public void GetBlockTextOrientations​(@Cast("int**")
                                             PointerPointer block_orientation,
                                             @Cast("bool**")
                                             PointerPointer vertical_writing)
        Return text orientation of each block as determined by an earlier run of layout analysis.
      • GetBlockTextOrientations

        public void GetBlockTextOrientations​(@ByPtrPtr
                                             IntBuffer block_orientation,
                                             @Cast("bool**") @ByPtrPtr
                                             boolean[] vertical_writing)
      • GetBlockTextOrientations

        public void GetBlockTextOrientations​(@ByPtrPtr
                                             int[] block_orientation,
                                             @Cast("bool**") @ByPtrPtr
                                             boolean[] vertical_writing)
      • GetUnichar

        @Cast("const char*")
        public BytePointer GetUnichar​(int unichar_id)
        This method returns the string form of the specified unichar.
      • GetDawg

        @Const
        public Dawg GetDawg​(int i)
        Return the pointer to the i-th dawg loaded into tesseract_ object.
      • NumDawgs

        public int NumDawgs()
        Return the number of dawgs loaded into tesseract_ object.
      • oem

        @Cast("tesseract::OcrEngineMode")
        public int oem()
      • set_min_orientation_margin

        public void set_min_orientation_margin​(double margin)