20 #ifndef TESSERACT_API_BASEAPI_H__
21 #define TESSERACT_API_BASEAPI_H__
23 #define TESSERACT_VERSION_STR "3.04.00"
24 #define TESSERACT_VERSION 0x030400
25 #define MAKE_VERSION(major, minor, patch) (((major) << 16) | ((minor) << 8) | \
60 class WERD_CHOICE_LIST;
68 class CubeRecoContext;
73 class LTRResultIterator;
75 class MutableIterator;
89 const char *
lang,
void *path);
91 const WERD_CHOICE_LIST &best_choices,
113 static const char* Version();
122 static size_t getOpenCLDevice(
void **device);
128 static void CatchSignals();
134 void SetInputName(
const char*
name);
142 const char* GetInputName();
143 void SetInputImage(Pix *pix);
144 Pix* GetInputImage();
145 int GetSourceYResolution();
146 const char* GetDatapath();
149 void SetOutputName(
const char* name);
164 bool SetVariable(
const char* name,
const char* value);
165 bool SetDebugVariable(
const char* name,
const char* value);
171 bool GetIntVariable(
const char *name,
int *value)
const;
172 bool GetBoolVariable(
const char *name,
bool *value)
const;
173 bool GetDoubleVariable(
const char *name,
double *value)
const;
179 const char *GetStringVariable(
const char *name)
const;
184 void PrintVariables(FILE *fp)
const;
189 bool GetVariableAsString(
const char *name,
STRING *val);
230 char **configs,
int configs_size,
233 bool set_only_non_debug_params);
235 return Init(datapath, language, oem,
NULL, 0,
NULL,
NULL,
false);
237 int Init(
const char* datapath,
const char* language) {
249 const char* GetInitLanguagesAsString()
const;
269 int InitLangMod(
const char* datapath,
const char* language);
275 void InitForAnalysePage();
283 void ReadConfigFile(
const char*
filename);
285 void ReadDebugConfigFile(
const char*
filename);
314 char* TesseractRect(
const unsigned char* imagedata,
315 int bytes_per_pixel,
int bytes_per_line,
316 int left,
int top,
int width,
int height);
322 void ClearAdaptiveClassifier();
341 void SetImage(
const unsigned char* imagedata,
int width,
int height,
342 int bytes_per_pixel,
int bytes_per_line);
354 void SetImage(Pix* pix);
360 void SetSourceResolution(
int ppi);
367 void SetRectangle(
int left,
int top,
int width,
int height);
377 if (thresholder_ !=
NULL)
379 thresholder_ = thresholder;
388 Pix* GetThresholdedImage();
395 Boxa* GetRegions(Pixa** pixa);
408 Boxa* GetTextlines(
const bool raw_image,
const int raw_padding,
409 Pixa** pixa,
int** blockids,
int** paraids);
414 return GetTextlines(
false, 0, pixa, blockids,
NULL);
425 Boxa* GetStrips(Pixa** pixa,
int** blockids);
432 Boxa* GetWords(Pixa** pixa);
442 Boxa* GetConnectedComponents(Pixa** cc);
458 const bool text_only,
const bool raw_image,
459 const int raw_padding,
460 Pixa** pixa,
int** blockids,
int** paraids);
463 const bool text_only,
464 Pixa** pixa,
int** blockids) {
465 return GetComponentImages(level, text_only,
false, 0, pixa, blockids,
NULL);
474 int GetThresholdedImageScaleFactor()
const;
499 return AnalyseLayout(
false);
517 int RecognizeForChopTest(
ETEXT_DESC* monitor);
541 bool ProcessPages(
const char*
filename,
const char* retry_config,
544 bool ProcessPagesInternal(
const char*
filename,
const char* retry_config,
556 bool ProcessPage(Pix* pix,
int page_index,
const char*
filename,
557 const char* retry_config,
int timeout_millisec,
591 char* GetHOCRText(
int page_number);
600 char* GetBoxText(
int page_number);
615 int* AllWordConfidences();
627 bool AdaptToWordStr(
PageSegMode mode,
const char* wordstr);
652 static void ClearPersistentCache();
660 int IsValidWord(
const char *word);
662 bool IsValidCharacter(
const char *utf8_character);
665 bool GetTextDirection(
int* out_offset,
float* out_slope);
686 int* num_features,
int* feature_outline_index);
692 static ROW* FindRowForBox(BLOCK_LIST* blocks,
int left,
int top,
693 int right,
int bottom);
699 void RunAdaptiveClassifier(
TBLOB* blob,
703 int* num_matches_returned);
706 const char* GetUnichar(
int unichar_id);
709 const Dawg *GetDawg(
int i)
const;
712 int NumDawgs()
const;
715 static ROW *MakeTessOCRRow(
float baseline,
float xheight,
716 float descender,
float ascender);
719 static TBLOB *MakeTBLOB(Pix *pix);
726 static void NormalizeTBLOB(
TBLOB *tblob,
ROW *row,
bool numeric_mode);
733 return last_oem_requested_;
741 void set_min_orientation_margin(
double margin);
747 void GetBlockTextOrientations(
int** block_orientation,
748 bool** vertical_writing);
751 BLOCK_LIST* FindLinesCreateBlockList();
758 static void DeleteBlockList(BLOCK_LIST* block_list);
803 TESS_LOCAL void AdaptToCharacter(
const char *unichar_repr,
822 TESS_LOCAL static int TesseractExtractResult(
char** text,
869 bool ProcessPagesFileList(FILE *fp,
871 const char* retry_config,
int timeout_millisec,
873 int tessedit_page_number);
875 bool ProcessPagesMultipageTiff(
const unsigned char *data,
878 const char* retry_config,
879 int timeout_millisec,
881 int tessedit_page_number);
888 #endif // TESSERACT_API_BASEAPI_H__
EquationDetect * equ_detect_
The equation detector.
int Init(const char *datapath, const char *language, OcrEngineMode oem)
TessCallback4< const UNICHARSET &, int, PageIterator *, Pix * > TruthCallback
struct TessResultRenderer TessResultRenderer
void SetThresholder(ImageThresholder *thresholder)
OcrEngineMode last_oem_requested_
Last ocr language mode requested.
TruthCallback * truth_cb_
PageIterator * AnalyseLayout()
TESS_LOCAL const PAGE_RES * GetPageRes() const
GenericVector< ParagraphModel * > * paragraph_models_
ImageThresholder * thresholder_
Image thresholding module.
Pix * input_image_
Image used for searchable PDF.
STRING * language_
Last initialized language.
Boxa * GetTextlines(Pixa **pixa, int **blockids)
void InitTruthCallback(TruthCallback *cb)
void(Wordrec::* FillLatticeFunc)(const MATRIX &ratings, const WERD_CHOICE_LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)
struct TessBaseAPI TessBaseAPI
STRING * output_file_
Name used by debug code.
float(Dict::* ParamsModelClassifyFunc)(const char *lang, void *path)
Tesseract *const tesseract() const
PAGE_RES * page_res_
The page-level data.
STRING * datapath_
Current location of tessdata.
STRING HOcrEscape(const char *text)
int Init(const char *datapath, const char *language)
double(Dict::* ProbabilityInContextFunc)(const char *lang, const char *context, int context_bytes, const char *character, int character_bytes)
void DetectParagraphs(int debug_level, GenericVector< RowInfo > *row_infos, GenericVector< PARA * > *row_owners, PARA_LIST *paragraphs, GenericVector< ParagraphModel * > *models)
Tesseract * osd_tesseract_
For orientation & script detection.
BLOCK_LIST * block_list_
The page layout.
INT_FEATURE_STRUCT * INT_FEATURE
OcrEngineMode const oem() const
int(Dict::* DictFunc)(void *void_dawg_args, UNICHAR_ID unichar_id, bool word_end) const
STRING * input_file_
Name used by training code.
bool recognition_done_
page_res_ contains recognition data.
Boxa * GetComponentImages(const PageIteratorLevel level, const bool text_only, Pixa **pixa, int **blockids)