public class TessAPI1 extends java.lang.Object implements com.sun.jna.Library, ITessAPI
Tesseract OCR 3.03 API
using
JNA Direct Mapping
.ITessAPI.CANCEL_FUNC, ITessAPI.EANYCODE_CHAR, ITessAPI.ETEXT_DESC, ITessAPI.TessBaseAPI, ITessAPI.TessMutableIterator, ITessAPI.TessOcrEngineMode, ITessAPI.TessOrientation, ITessAPI.TessPageIterator, ITessAPI.TessPageIteratorLevel, ITessAPI.TessPageSegMode, ITessAPI.TessPolyBlockType, ITessAPI.TessResultIterator, ITessAPI.TessResultRenderer, ITessAPI.TessTextlineOrder, ITessAPI.TessWritingDirection, ITessAPI.TimeVal
Constructor and Description |
---|
TessAPI1() |
Modifier and Type | Method and Description |
---|---|
static int |
TessBaseAPIAdaptToWordStr(ITessAPI.TessBaseAPI handle,
int mode,
java.lang.String wordstr)
Applies the given word to the adaptive classifier if possible.
|
static com.sun.jna.ptr.IntByReference |
TessBaseAPIAllWordConfidences(ITessAPI.TessBaseAPI handle)
Returns an array of all word confidences, terminated by -1.
|
static ITessAPI.TessPageIterator |
TessBaseAPIAnalyseLayout(ITessAPI.TessBaseAPI handle)
Runs page layout analysis in the mode set by
SetPageSegMode . |
static void |
TessBaseAPIClear(ITessAPI.TessBaseAPI handle)
Free up recognition results and any stored image data, without actually
freeing any recognition data that would be time-consuming to reload.
|
static void |
TessBaseAPIClearAdaptiveClassifier(ITessAPI.TessBaseAPI handle)
Call between pages or documents etc to free up memory and forget adaptive
data.
|
static void |
TessBaseAPIClearPersistentCache(ITessAPI.TessBaseAPI handle)
Clear any library-level memory caches.
|
static ITessAPI.TessBaseAPI |
TessBaseAPICreate()
Creates an instance of the base class for all Tesseract APIs.
|
static void |
TessBaseAPIDelete(ITessAPI.TessBaseAPI handle)
Disposes the TesseractAPI instance.
|
static void |
TessBaseAPIDumpPGM(ITessAPI.TessBaseAPI handle,
java.lang.String filename)
Dump the internal binary image to a PGM file.
|
static void |
TessBaseAPIEnd(ITessAPI.TessBaseAPI handle)
Close down tesseract and free up all memory.
|
static com.sun.jna.ptr.PointerByReference |
TessBaseAPIGetAvailableLanguagesAsVector(ITessAPI.TessBaseAPI handle)
Returns the available languages in the vector of STRINGs.
|
static int |
TessBaseAPIGetBoolVariable(ITessAPI.TessBaseAPI handle,
java.lang.String name,
java.nio.IntBuffer value)
Get the value of an internal bool parameter.
|
static com.sun.jna.Pointer |
TessBaseAPIGetBoxText(ITessAPI.TessBaseAPI handle,
int page_number)
The recognized text is returned as a char* which is coded as a UTF8 box
file and must be freed with the delete [] operator.
|
static java.lang.String |
TessBaseAPIGetDatapath(ITessAPI.TessBaseAPI handle) |
static int |
TessBaseAPIGetDoubleVariable(ITessAPI.TessBaseAPI handle,
java.lang.String name,
java.nio.DoubleBuffer value)
Get the value of an internal double parameter.
|
static com.sun.jna.Pointer |
TessBaseAPIGetHOCRText(ITessAPI.TessBaseAPI handle,
int page_number)
Make a HTML-formatted string with hOCR markup from the internal data
structures.
|
static java.lang.String |
TessBaseAPIGetInitLanguagesAsString(ITessAPI.TessBaseAPI handle)
Returns the languages string used in the last valid initialization.
|
static java.lang.String |
TessBaseAPIGetInputName(ITessAPI.TessBaseAPI handle)
These functions are required for searchable PDF output.
|
static int |
TessBaseAPIGetIntVariable(ITessAPI.TessBaseAPI handle,
java.lang.String name,
java.nio.IntBuffer value)
Get the value of an internal int parameter.
|
static ITessAPI.TessResultIterator |
TessBaseAPIGetIterator(ITessAPI.TessBaseAPI handle)
Get a reading-order iterator to the results of LayoutAnalysis and/or
Recognize . |
static com.sun.jna.ptr.PointerByReference |
TessBaseAPIGetLoadedLanguagesAsVector(ITessAPI.TessBaseAPI handle)
Returns the loaded languages in the vector of STRINGs.
|
static ITessAPI.TessMutableIterator |
TessBaseAPIGetMutableIterator(ITessAPI.TessBaseAPI handle)
Get a mutable iterator to the results of LayoutAnalysis and/or
Recognize . |
static int |
TessBaseAPIGetPageSegMode(ITessAPI.TessBaseAPI handle)
Return the current page segmentation mode.
|
static int |
TessBaseAPIGetSourceYResolution(ITessAPI.TessBaseAPI handle) |
static java.lang.String |
TessBaseAPIGetStringVariable(ITessAPI.TessBaseAPI handle,
java.lang.String name)
Get the value of an internal string parameter.
|
static int |
TessBaseAPIGetTextDirection(ITessAPI.TessBaseAPI handle,
java.nio.IntBuffer out_offset,
java.nio.FloatBuffer out_slope)
Gets text direction.
|
static int |
TessBaseAPIGetThresholdedImageScaleFactor(ITessAPI.TessBaseAPI handle) |
static java.lang.String |
TessBaseAPIGetUnichar(ITessAPI.TessBaseAPI handle,
int unichar_id)
Gets the string of the specified unichar.
|
static com.sun.jna.Pointer |
TessBaseAPIGetUNLVText(ITessAPI.TessBaseAPI handle)
The recognized text is returned as a char* which is coded as UNLV format
Latin-1 with specific reject and suspect codes and must be freed with the
delete [] operator.
|
static com.sun.jna.Pointer |
TessBaseAPIGetUTF8Text(ITessAPI.TessBaseAPI handle)
The recognized text is returned as a char* which is coded as UTF-8 and
must be freed with the delete [] operator.
|
static int |
TessBaseAPIInit1(ITessAPI.TessBaseAPI handle,
java.lang.String datapath,
java.lang.String language,
int oem,
com.sun.jna.ptr.PointerByReference configs,
int configs_size)
Instances are now mostly thread-safe and totally independent, but some
global parameters remain.
|
static int |
TessBaseAPIInit2(ITessAPI.TessBaseAPI handle,
java.lang.String datapath,
java.lang.String language,
int oem) |
static int |
TessBaseAPIInit3(ITessAPI.TessBaseAPI handle,
java.lang.String datapath,
java.lang.String language) |
static int |
TessBaseAPIInit4(ITessAPI.TessBaseAPI handle,
java.lang.String datapath,
java.lang.String language,
int oem,
com.sun.jna.ptr.PointerByReference configs,
int configs_size,
com.sun.jna.ptr.PointerByReference vars_vec,
com.sun.jna.ptr.PointerByReference vars_values,
NativeSize vars_vec_size,
int set_only_non_debug_params) |
static void |
TessBaseAPIInitForAnalysePage(ITessAPI.TessBaseAPI handle)
Init only for page layout analysis.
|
static int |
TessBaseAPIInitLangMod(ITessAPI.TessBaseAPI handle,
java.lang.String datapath,
java.lang.String language)
Init only the lang model component of Tesseract.
|
static int |
TessBaseAPIIsValidWord(ITessAPI.TessBaseAPI handle,
java.lang.String word)
Check whether a word is valid according to Tesseract's language model.
|
static int |
TessBaseAPIMeanTextConf(ITessAPI.TessBaseAPI handle)
Returns the average word confidence for Tesseract page result.
|
static void |
TessBaseAPIPrintVariablesToFile(ITessAPI.TessBaseAPI handle,
java.lang.String filename)
Print Tesseract parameters to the given file.
Note: Must not be the first method called after instance create. |
static com.sun.jna.Pointer |
TessBaseAPIProcessPages(ITessAPI.TessBaseAPI handle,
java.lang.String filename,
java.lang.String retry_config,
int timeout_millisec)
Recognizes all the pages in the named file, as a multi-page tiff or list
of filenames, or single image, and gets the appropriate kind of text
according to parameters:
tessedit_create_boxfile ,
tessedit_make_boxes_from_boxes ,
tessedit_write_unlv , tessedit_create_hocr . |
static int |
TessBaseAPIProcessPages1(ITessAPI.TessBaseAPI handle,
java.lang.String filename,
java.lang.String retry_config,
int timeout_millisec,
ITessAPI.TessResultRenderer renderer) |
static void |
TessBaseAPIReadConfigFile(ITessAPI.TessBaseAPI handle,
java.lang.String filename,
int init_only)
Read a "config" file containing a set of param, value pairs.
|
static int |
TessBaseAPIRecognize(ITessAPI.TessBaseAPI handle,
ITessAPI.ETEXT_DESC monitor)
Recognize the image from
SetAndThresholdImage , generating
Tesseract internal structures. |
static int |
TessBaseAPIRecognizeForChopTest(ITessAPI.TessBaseAPI handle,
ITessAPI.ETEXT_DESC monitor)
Variant on Recognize used for testing chopper.
|
static com.sun.jna.Pointer |
TessBaseAPIRect(ITessAPI.TessBaseAPI handle,
java.nio.ByteBuffer 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.
|
static void |
TessBaseAPISetImage(ITessAPI.TessBaseAPI handle,
java.nio.ByteBuffer imagedata,
int width,
int height,
int bytes_per_pixel,
int bytes_per_line)
Provide an image for Tesseract to recognize.
|
static void |
TessBaseAPISetInputName(ITessAPI.TessBaseAPI handle,
java.lang.String name)
Set the name of the input file.
|
static void |
TessBaseAPISetOutputName(ITessAPI.TessBaseAPI handle,
java.lang.String name)
Set the name of the bonus output files.
|
static void |
TessBaseAPISetPageSegMode(ITessAPI.TessBaseAPI handle,
int mode)
Set the current page segmentation mode.
|
static void |
TessBaseAPISetRectangle(ITessAPI.TessBaseAPI handle,
int left,
int top,
int width,
int height)
Restrict recognition to a sub-rectangle of the image.
|
static void |
TessBaseAPISetSourceResolution(ITessAPI.TessBaseAPI handle,
int ppi)
Set the resolution of the source image in pixels per inch so font size
information can be calculated in results.
|
static int |
TessBaseAPISetVariable(ITessAPI.TessBaseAPI handle,
java.lang.String name,
java.lang.String 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.
|
static ITessAPI.TessResultRenderer |
TessBoxTextRendererCreate() |
static void |
TessDeleteIntArray(java.nio.IntBuffer arr)
Deallocates the memory block occupied by integer array.
|
static void |
TessDeleteResultRenderer(ITessAPI.TessResultRenderer renderer) |
static void |
TessDeleteText(com.sun.jna.Pointer text)
Deallocates the memory block occupied by text.
|
static void |
TessDeleteTextArray(com.sun.jna.ptr.PointerByReference arr)
Deallocates the memory block occupied by text array.
|
static ITessAPI.TessResultRenderer |
TessHOcrRendererCreate() |
static int |
TessPageIteratorBaseline(ITessAPI.TessPageIterator handle,
int level,
java.nio.IntBuffer x1,
java.nio.IntBuffer y1,
java.nio.IntBuffer x2,
java.nio.IntBuffer y2)
Returns the baseline of the current object at the given level.
|
static void |
TessPageIteratorBegin(ITessAPI.TessPageIterator handle)
Resets the iterator to point to the start of the page.
|
static int |
TessPageIteratorBlockType(ITessAPI.TessPageIterator handle)
Returns the type of the current block.
|
static int |
TessPageIteratorBoundingBox(ITessAPI.TessPageIterator handle,
int level,
java.nio.IntBuffer left,
java.nio.IntBuffer top,
java.nio.IntBuffer right,
java.nio.IntBuffer bottom)
Returns the bounding rectangle of the current object at the given level
in coordinates of the original image.
|
static ITessAPI.TessPageIterator |
TessPageIteratorCopy(ITessAPI.TessPageIterator handle)
Creates a copy of the specified PageIterator instance.
|
static void |
TessPageIteratorDelete(ITessAPI.TessPageIterator handle)
Deletes the specified PageIterator instance.
|
static int |
TessPageIteratorIsAtBeginningOf(ITessAPI.TessPageIterator handle,
int level)
Returns TRUE if the iterator is at the start of an object at the given
level.
|
static int |
TessPageIteratorIsAtFinalElement(ITessAPI.TessPageIterator handle,
int level,
int element)
Returns whether the iterator is positioned at the last element in a given
level.
|
static int |
TessPageIteratorNext(ITessAPI.TessPageIterator handle,
int level)
Moves to the start of the next object at the given level in the page
hierarchy, and returns false if the end of the page was reached.
|
static void |
TessPageIteratorOrientation(ITessAPI.TessPageIterator handle,
java.nio.IntBuffer orientation,
java.nio.IntBuffer writing_direction,
java.nio.IntBuffer textline_order,
java.nio.FloatBuffer deskew_angle)
Returns the orientation.
|
static ITessAPI.TessResultRenderer |
TessPDFRendererCreate(java.lang.String datadir) |
static float |
TessResultIteratorConfidence(ITessAPI.TessResultIterator handle,
int level)
Returns the mean confidence of the current object at the given level.
|
static ITessAPI.TessResultIterator |
TessResultIteratorCopy(ITessAPI.TessResultIterator handle)
Creates a copy of the specified ResultIterator instance.
|
static void |
TessResultIteratorDelete(ITessAPI.TessResultIterator handle)
Deletes the specified ResultIterator handle.
|
static ITessAPI.TessPageIterator |
TessResultIteratorGetPageIterator(ITessAPI.TessResultIterator handle)
Gets the PageIterator of the specified ResultIterator instance.
|
static ITessAPI.TessPageIterator |
TessResultIteratorGetPageIteratorConst(ITessAPI.TessResultIterator handle)
Gets the PageIterator of the specified ResultIterator instance.
|
static com.sun.jna.Pointer |
TessResultIteratorGetUTF8Text(ITessAPI.TessResultIterator handle,
int level)
Returns the null terminated UTF-8 encoded text string for the current
object at the given level.
|
static int |
TessResultIteratorSymbolIsDropcap(ITessAPI.TessResultIterator handle)
Returns TRUE if the current symbol is a dropcap.
|
static int |
TessResultIteratorSymbolIsSubscript(ITessAPI.TessResultIterator handle)
Returns TRUE if the current symbol is a subscript.
|
static int |
TessResultIteratorSymbolIsSuperscript(ITessAPI.TessResultIterator handle)
Returns TRUE if the current symbol is a superscript.
|
static java.lang.String |
TessResultIteratorWordFontAttributes(ITessAPI.TessResultIterator handle,
java.nio.IntBuffer is_bold,
java.nio.IntBuffer is_italic,
java.nio.IntBuffer is_underlined,
java.nio.IntBuffer is_monospace,
java.nio.IntBuffer is_serif,
java.nio.IntBuffer is_smallcaps,
java.nio.IntBuffer pointsize,
java.nio.IntBuffer font_id)
Returns the font attributes of the current word.
|
static int |
TessResultIteratorWordIsFromDictionary(ITessAPI.TessResultIterator handle)
Returns TRUE if the current word was found in a dictionary.
|
static int |
TessResultIteratorWordIsNumeric(ITessAPI.TessResultIterator handle)
Returns TRUE if the current word is numeric.
|
static int |
TessResultRendererAddError(ITessAPI.TessResultRenderer renderer,
com.sun.jna.ptr.PointerByReference api) |
static int |
TessResultRendererAddImage(ITessAPI.TessResultRenderer renderer,
com.sun.jna.ptr.PointerByReference api) |
static int |
TessResultRendererBeginDocument(ITessAPI.TessResultRenderer renderer,
java.lang.String title) |
static int |
TessResultRendererEndDocument(ITessAPI.TessResultRenderer renderer) |
static com.sun.jna.Pointer |
TessResultRendererExtention(ITessAPI.TessResultRenderer renderer) |
static int |
TessResultRendererGetOutput(ITessAPI.TessResultRenderer renderer,
com.sun.jna.ptr.PointerByReference data,
com.sun.jna.ptr.IntByReference data_len) |
static int |
TessResultRendererImageNum(ITessAPI.TessResultRenderer renderer) |
static void |
TessResultRendererInsert(ITessAPI.TessResultRenderer renderer,
ITessAPI.TessResultRenderer next) |
static ITessAPI.TessResultRenderer |
TessResultRendererNext(ITessAPI.TessResultRenderer renderer) |
static com.sun.jna.Pointer |
TessResultRendererTitle(ITessAPI.TessResultRenderer renderer) |
static com.sun.jna.Pointer |
TessResultRendererTypename(ITessAPI.TessResultRenderer renderer) |
static ITessAPI.TessResultRenderer |
TessTextRendererCreate() |
static ITessAPI.TessResultRenderer |
TessUnlvRendererCreate() |
static java.lang.String |
TessVersion()
Gets the version identifier.
|
public static java.lang.String TessVersion()
public static void TessDeleteText(com.sun.jna.Pointer text)
text
- the pointer to textpublic static void TessDeleteTextArray(com.sun.jna.ptr.PointerByReference arr)
arr
- text array pointer referencepublic static void TessDeleteIntArray(java.nio.IntBuffer arr)
arr
- int arraypublic static ITessAPI.TessResultRenderer TessTextRendererCreate()
public static ITessAPI.TessResultRenderer TessHOcrRendererCreate()
public static ITessAPI.TessResultRenderer TessPDFRendererCreate(java.lang.String datadir)
public static ITessAPI.TessResultRenderer TessUnlvRendererCreate()
public static ITessAPI.TessResultRenderer TessBoxTextRendererCreate()
public static void TessDeleteResultRenderer(ITessAPI.TessResultRenderer renderer)
public static void TessResultRendererInsert(ITessAPI.TessResultRenderer renderer, ITessAPI.TessResultRenderer next)
public static ITessAPI.TessResultRenderer TessResultRendererNext(ITessAPI.TessResultRenderer renderer)
public static int TessResultRendererBeginDocument(ITessAPI.TessResultRenderer renderer, java.lang.String title)
public static int TessResultRendererAddImage(ITessAPI.TessResultRenderer renderer, com.sun.jna.ptr.PointerByReference api)
public static int TessResultRendererAddError(ITessAPI.TessResultRenderer renderer, com.sun.jna.ptr.PointerByReference api)
public static int TessResultRendererEndDocument(ITessAPI.TessResultRenderer renderer)
public static int TessResultRendererGetOutput(ITessAPI.TessResultRenderer renderer, com.sun.jna.ptr.PointerByReference data, com.sun.jna.ptr.IntByReference data_len)
public static com.sun.jna.Pointer TessResultRendererTypename(ITessAPI.TessResultRenderer renderer)
public static com.sun.jna.Pointer TessResultRendererExtention(ITessAPI.TessResultRenderer renderer)
public static com.sun.jna.Pointer TessResultRendererTitle(ITessAPI.TessResultRenderer renderer)
public static int TessResultRendererImageNum(ITessAPI.TessResultRenderer renderer)
public static ITessAPI.TessBaseAPI TessBaseAPICreate()
public static void TessBaseAPIDelete(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static void TessBaseAPISetInputName(ITessAPI.TessBaseAPI handle, java.lang.String name)
handle
- the TesseractAPI instancename
- name of the input filepublic static java.lang.String TessBaseAPIGetInputName(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static int TessBaseAPIGetSourceYResolution(ITessAPI.TessBaseAPI handle)
public static java.lang.String TessBaseAPIGetDatapath(ITessAPI.TessBaseAPI handle)
public static void TessBaseAPISetOutputName(ITessAPI.TessBaseAPI handle, java.lang.String name)
handle
- the TesseractAPI instancename
- name of the output filepublic static int TessBaseAPISetVariable(ITessAPI.TessBaseAPI handle, java.lang.String name, java.lang.String value)
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()
.Init()
. Only works for non-init
variables (init variables should be passed to Init()
).handle
- the TesseractAPI instancename
- name of the inputvalue
- variable valuepublic static int TessBaseAPIGetIntVariable(ITessAPI.TessBaseAPI handle, java.lang.String name, java.nio.IntBuffer value)
handle
- the TesseractAPI instancename
- name of the inputvalue
- pass the int buffer valuepublic static int TessBaseAPIGetBoolVariable(ITessAPI.TessBaseAPI handle, java.lang.String name, java.nio.IntBuffer value)
handle
- the TesseractAPI instancename
- pass the name of the variablevalue
- pass the int buffer valuepublic static int TessBaseAPIGetDoubleVariable(ITessAPI.TessBaseAPI handle, java.lang.String name, java.nio.DoubleBuffer value)
handle
- the TesseractAPI instancename
- pass the name of the variablevalue
- pass the double buffer valuepublic static java.lang.String TessBaseAPIGetStringVariable(ITessAPI.TessBaseAPI handle, java.lang.String name)
handle
- the TesseractAPI instancename
- pass the name of the variablepublic static void TessBaseAPIPrintVariablesToFile(ITessAPI.TessBaseAPI handle, java.lang.String filename)
handle
- the TesseractAPI instancefilename
- name of the file where the variables will be persistedpublic static int TessBaseAPIInit1(ITessAPI.TessBaseAPI handle, java.lang.String datapath, java.lang.String language, int oem, com.sun.jna.ptr.PointerByReference configs, int configs_size)
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.Init
are those listed
above here in the class definition.Init
multiple times on the same instance to change language,
or just to reset the classifier. Languages may specify internally that
they want to be loaded with one or more other languages, so the ~
sign is available to override that. E.g., 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
.Init
.set_only_non_debug_params
is true, only params that do
not contain "debug" in the name will be set.handle
- the TesseractAPI instancedatapath
- The datapath
must be the name of the parent
directory of tessdata
and must end in
/. Any name after the last / will be stripped.language
- The language is (usually) an ISO 639-3
string or NULL
will default to eng
. The
language may be a string of the form [~]<lang>[+[~]<lang>] indicating
that multiple languages are to be loaded. E.g., hin+eng
will
load Hindi and English.oem
- ocr engine modeconfigs
- pointer configurationconfigs_size
- pointer configuration sizepublic static int TessBaseAPIInit2(ITessAPI.TessBaseAPI handle, java.lang.String datapath, java.lang.String language, int oem)
handle
- the TesseractAPI instancedatapath
- The datapath
must be the name of the parent
directory of tessdata
and must end in
/. Any name after the last / will be stripped.language
- The language is (usually) an ISO 639-3
string or NULL
will default to eng
. The
language may be a string of the form [~]<lang>[+[~]<lang>] indicating
that multiple languages are to be loaded. E.g., hin+eng
will
load Hindi and English.oem
- ocr engine modepublic static int TessBaseAPIInit3(ITessAPI.TessBaseAPI handle, java.lang.String datapath, java.lang.String language)
handle
- the TesseractAPI instancedatapath
- The datapath
must be the name of the parent
directory of tessdata
and must end in
/. Any name after the last / will be stripped.language
- The language is (usually) an ISO 639-3
string or NULL
will default to eng
. The
language may be a string of the form [~]<lang>[+[~]<lang>] indicating
that multiple languages are to be loaded. E.g., hin+eng
will
load Hindi and English.public static int TessBaseAPIInit4(ITessAPI.TessBaseAPI handle, java.lang.String datapath, java.lang.String language, int oem, com.sun.jna.ptr.PointerByReference configs, int configs_size, com.sun.jna.ptr.PointerByReference vars_vec, com.sun.jna.ptr.PointerByReference vars_values, NativeSize vars_vec_size, int set_only_non_debug_params)
handle
- the TesseractAPI instancedatapath
- The datapath
must be the name of the parent
directory of tessdata
and must end in
/. Any name after the last / will be stripped.language
- The language is (usually) an ISO 639-3
string or NULL
will default to eng
. The
language may be a string of the form [~]<lang>[+[~]<lang>] indicating
that multiple languages are to be loaded. E.g., hin+eng
will
load Hindi and English.oem
- ocr engine modeconfigs
- pointer configurationconfigs_size
- pointer configuration sizevars_vec
- vars_values
- vars_vec_size
- set_only_non_debug_params
- public static java.lang.String TessBaseAPIGetInitLanguagesAsString(ITessAPI.TessBaseAPI handle)
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.handle
- the TesseractAPI instancepublic static com.sun.jna.ptr.PointerByReference TessBaseAPIGetLoadedLanguagesAsVector(ITessAPI.TessBaseAPI handle)
Init
, including those loaded as
dependencies of other loaded languages.handle
- the TesseractAPI instancepublic static com.sun.jna.ptr.PointerByReference TessBaseAPIGetAvailableLanguagesAsVector(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static int TessBaseAPIInitLangMod(ITessAPI.TessBaseAPI handle, java.lang.String datapath, java.lang.String language)
SetVariable
and
IsValidWord
. WARNING: temporary! This function will be
removed from here and placed in a separate API at some future time.handle
- the TesseractAPI instancedatapath
- The datapath
must be the name of the parent
directory of tessdata
and must end in
/. Any name after the last / will be stripped.language
- The language is (usually) an ISO 639-3
string or NULL
will default to eng. The language may be a
string of the form [~]<lang>[+[~]<lang>] indicating that multiple
languages are to be loaded. E.g., hin+eng will load Hindi and English.public static void TessBaseAPIInitForAnalysePage(ITessAPI.TessBaseAPI handle)
SetImage
and AnalysePage
. Calls that attempt
recognition will generate an error.handle
- the TesseractAPI instancepublic static void TessBaseAPIReadConfigFile(ITessAPI.TessBaseAPI handle, java.lang.String filename, int init_only)
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()
).handle
- the TesseractAPI instancefilename
- relative or absolute path for the "config" file
containing a set of param and value pairsinit_only
- public static void TessBaseAPISetPageSegMode(ITessAPI.TessBaseAPI handle, int mode)
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)
.handle
- the TesseractAPI instancemode
- tesseract page segment modepublic static int TessBaseAPIGetPageSegMode(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static com.sun.jna.Pointer TessBaseAPIRect(ITessAPI.TessBaseAPI handle, java.nio.ByteBuffer imagedata, int bytes_per_pixel, int bytes_per_line, int left, int top, int width, int height)
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.TesseractRect
is the simplified convenience
interface. For advanced uses, use SetImage
, (optionally)
SetRectangle
, Recognize
, and one or more of the
Get*Text
functions below.handle
- the TesseractAPI instanceimagedata
- image byte bufferbytes_per_pixel
- bytes per pixelbytes_per_line
- bytes per lineleft
- image lefttop
- image topwidth
- image widthheight
- image heightpublic static void TessBaseAPIClearAdaptiveClassifier(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static void TessBaseAPISetImage(ITessAPI.TessBaseAPI handle, java.nio.ByteBuffer imagedata, int width, int height, int bytes_per_pixel, int bytes_per_line)
TesseractRect
above. Does not copy the image buffer, or take
ownership. The source image may be destroyed after Recognize is called,
either explicitly or implicitly via one of the Get*Text
functions. 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.handle
- the TesseractAPI instanceimagedata
- image byte bufferwidth
- image widthheight
- image heightbytes_per_pixel
- bytes per pixelbytes_per_line
- bytes per linepublic static void TessBaseAPISetSourceResolution(ITessAPI.TessBaseAPI handle, int ppi)
SetImage()
.handle
- the TesseractAPI instanceppi
- source resolution valuepublic static void TessBaseAPISetRectangle(ITessAPI.TessBaseAPI handle, int left, int top, int width, int height)
SetImage
. Each SetRectangle
clears the
recognition results so multiple rectangles can be recognized with the
same image.handle
- the TesseractAPI instanceleft
- valuetop
- valuewidth
- valueheight
- valuepublic static int TessBaseAPIGetThresholdedImageScaleFactor(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static void TessBaseAPIDumpPGM(ITessAPI.TessBaseAPI handle, java.lang.String filename)
handle
- the TesseractAPI instancefilename
- pgm file namepublic static ITessAPI.TessPageIterator TessBaseAPIAnalyseLayout(ITessAPI.TessBaseAPI handle)
SetPageSegMode
.
May optionally be called prior to Recognize
to get access to
just the page layout results. Returns an iterator to the results. Returns
NULL
on error. 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
.handle
- the TesseractAPI instancepublic static int TessBaseAPIRecognize(ITessAPI.TessBaseAPI handle, ITessAPI.ETEXT_DESC monitor)
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
.handle
- the TesseractAPI instancemonitor
- the result as Tesseract internal structurespublic static int TessBaseAPIRecognizeForChopTest(ITessAPI.TessBaseAPI handle, ITessAPI.ETEXT_DESC monitor)
handle
- the TesseractAPI instancemonitor
- the result as Tesseract internal structurespublic static ITessAPI.TessResultIterator TessBaseAPIGetIterator(ITessAPI.TessBaseAPI handle)
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.handle
- the TesseractAPI instancepublic static ITessAPI.TessMutableIterator TessBaseAPIGetMutableIterator(ITessAPI.TessBaseAPI handle)
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
.handle
- the TesseractAPI instancepublic static com.sun.jna.Pointer TessBaseAPIProcessPages(ITessAPI.TessBaseAPI handle, java.lang.String filename, java.lang.String retry_config, int timeout_millisec)
tessedit_create_boxfile
,
tessedit_make_boxes_from_boxes
,
tessedit_write_unlv
, tessedit_create_hocr
.
Calls ProcessPage on each page in the input file, which may be a
multi-page tiff, single-page other file format, or a plain text list of
images to read. If tessedit_page_number is non-negative, processing
begins at that page of a multi-page tiff file, or filelist. The text is
returned in text_out. Returns false on error. If non-zero
timeout_millisec terminates processing after the timeout on a single
page. If non-NULL and non-empty, and some page fails for some reason, the
page is reprocessed with the retry_config config file. Useful for
interactively debugging a bad page.handle
- the TesseractAPI instancefilename
- multi-page tiff or list of filenamesretry_config
- retry config valuestimeout_millisec
- timeout valuepublic static int TessBaseAPIProcessPages1(ITessAPI.TessBaseAPI handle, java.lang.String filename, java.lang.String retry_config, int timeout_millisec, ITessAPI.TessResultRenderer renderer)
public static com.sun.jna.Pointer TessBaseAPIGetUTF8Text(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static com.sun.jna.Pointer TessBaseAPIGetHOCRText(ITessAPI.TessBaseAPI handle, int page_number)
handle
- the TesseractAPI instancepage_number
- page numberpublic static com.sun.jna.Pointer TessBaseAPIGetBoxText(ITessAPI.TessBaseAPI handle, int page_number)
handle
- the TesseractAPI instancepage_number
- number of the pagepublic static com.sun.jna.Pointer TessBaseAPIGetUNLVText(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static int TessBaseAPIMeanTextConf(ITessAPI.TessBaseAPI handle)
handle
- the TesseractAPI instancepublic static com.sun.jna.ptr.IntByReference TessBaseAPIAllWordConfidences(ITessAPI.TessBaseAPI handle)
GetUTF8Text
.handle
- the TesseractAPI instancepublic static int TessBaseAPIAdaptToWordStr(ITessAPI.TessBaseAPI handle, int mode, java.lang.String wordstr)
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.handle
- the TesseractAPI instancemode
- tesseract page segment modewordstr
- 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.public static void TessBaseAPIClear(ITessAPI.TessBaseAPI handle)
SetImage
or
TesseractRect
before doing any Recognize
or
Get*
operation.handle
- the TesseractAPI instancepublic static void TessBaseAPIEnd(ITessAPI.TessBaseAPI handle)
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.handle
- the TesseractAPI instancepublic static int TessBaseAPIIsValidWord(ITessAPI.TessBaseAPI handle, java.lang.String word)
handle
- the TesseractAPI instanceword
- word valuepublic static int TessBaseAPIGetTextDirection(ITessAPI.TessBaseAPI handle, java.nio.IntBuffer out_offset, java.nio.FloatBuffer out_slope)
handle
- the TesseractAPI instanceout_offset
- offsetout_slope
- slopepublic static void TessBaseAPIClearPersistentCache(ITessAPI.TessBaseAPI handle)
Init()
and
End()
of individual TessBaseAPI's. This function allows the
clearing of these caches.handle
- the TesseractAPI instancepublic static java.lang.String TessBaseAPIGetUnichar(ITessAPI.TessBaseAPI handle, int unichar_id)
handle
- the TesseractAPI instanceunichar_id
- the unichar idpublic static void TessPageIteratorDelete(ITessAPI.TessPageIterator handle)
handle
- the TessPageIterator instancepublic static ITessAPI.TessPageIterator TessPageIteratorCopy(ITessAPI.TessPageIterator handle)
handle
- the TessPageIterator instancepublic static void TessPageIteratorBegin(ITessAPI.TessPageIterator handle)
handle
- the TessPageIterator instancepublic static int TessPageIteratorNext(ITessAPI.TessPageIterator handle, int level)
PTIsTextType(BLockType())
is false for non-text blocks.handle
- the TessPageIterator instancelevel
- tesseract page levelpublic static int TessPageIteratorIsAtBeginningOf(ITessAPI.TessPageIterator handle, int level)
handle
- the TessPageIterator instancelevel
- tesseract page levelpublic static int TessPageIteratorIsAtFinalElement(ITessAPI.TessPageIterator handle, int level, int element)
handle
- the TessPageIterator instancelevel
- tesseract page levelelement
- page iterator levelpublic static int TessPageIteratorBoundingBox(ITessAPI.TessPageIterator handle, int level, java.nio.IntBuffer left, java.nio.IntBuffer top, java.nio.IntBuffer right, java.nio.IntBuffer bottom)
handle
- the TessPageIterator instancelevel
- tesseract page levelleft
- int buffer positiontop
- int buffer positionright
- int buffer positionbottom
- int buffer positionpublic static int TessPageIteratorBlockType(ITessAPI.TessPageIterator handle)
handle
- the TessPageIterator instancepublic static int TessPageIteratorBaseline(ITessAPI.TessPageIterator handle, int level, java.nio.IntBuffer x1, java.nio.IntBuffer y1, java.nio.IntBuffer x2, java.nio.IntBuffer y2)
handle
- the TessPageIterator instancelevel
- tesseract page levelx1
- int buffer positiony1
- int buffer positionx2
- int buffer positiony2
- int buffer positionpublic static void TessPageIteratorOrientation(ITessAPI.TessPageIterator handle, java.nio.IntBuffer orientation, java.nio.IntBuffer writing_direction, java.nio.IntBuffer textline_order, java.nio.FloatBuffer deskew_angle)
handle
- the TessPageIterator instanceorientation
- orientation valuewriting_direction
- writing direction valuetextline_order
- text line orderdeskew_angle
- deskew anglepublic static void TessResultIteratorDelete(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instancepublic static ITessAPI.TessResultIterator TessResultIteratorCopy(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instancepublic static ITessAPI.TessPageIterator TessResultIteratorGetPageIterator(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instancepublic static ITessAPI.TessPageIterator TessResultIteratorGetPageIteratorConst(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instancepublic static com.sun.jna.Pointer TessResultIteratorGetUTF8Text(ITessAPI.TessResultIterator handle, int level)
handle
- the TessResultIterator instancelevel
- tesseract page levelpublic static float TessResultIteratorConfidence(ITessAPI.TessResultIterator handle, int level)
handle
- the TessResultIterator instancelevel
- tesseract page levelpublic static java.lang.String TessResultIteratorWordFontAttributes(ITessAPI.TessResultIterator handle, java.nio.IntBuffer is_bold, java.nio.IntBuffer is_italic, java.nio.IntBuffer is_underlined, java.nio.IntBuffer is_monospace, java.nio.IntBuffer is_serif, java.nio.IntBuffer is_smallcaps, java.nio.IntBuffer pointsize, java.nio.IntBuffer font_id)
Init
, SetImage
, End
or deleting
the TessBaseAPI. Pointsize is returned in printers points (1/72 inch).handle
- the TessResultIterator instanceis_bold
- font attributeis_italic
- font attributeis_underlined
- font attributeis_monospace
- font attributeis_serif
- font attributeis_smallcaps
- font attributepointsize
- font attributefont_id
- font attributepublic static int TessResultIteratorWordIsFromDictionary(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instancepublic static int TessResultIteratorWordIsNumeric(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instancepublic static int TessResultIteratorSymbolIsSuperscript(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instancepublic static int TessResultIteratorSymbolIsSubscript(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instancepublic static int TessResultIteratorSymbolIsDropcap(ITessAPI.TessResultIterator handle)
handle
- the TessResultIterator instance