Go to the documentation of this file.
19 #ifndef TESSERACT_API_BASEAPI_H_
20 #define TESSERACT_API_BASEAPI_H_
56 class WERD_CHOICE_LIST;
68 class LTRResultIterator;
70 class MutableIterator;
99 static const char* Version();
108 static size_t getOpenCLDevice(
void **device);
114 static void CatchSignals();
120 void SetInputName(
const char* name);
128 const char* GetInputName();
130 void SetInputImage(Pix *pix);
131 Pix* GetInputImage();
132 int GetSourceYResolution();
133 const char* GetDatapath();
136 void SetOutputName(
const char* name);
151 bool SetVariable(
const char* name,
const char* value);
152 bool SetDebugVariable(
const char* name,
const char* value);
158 bool GetIntVariable(
const char *name,
int *value)
const;
159 bool GetBoolVariable(
const char *name,
bool *value)
const;
160 bool GetDoubleVariable(
const char *name,
double *value)
const;
166 const char *GetStringVariable(
const char *name)
const;
171 void PrintVariables(FILE *fp)
const;
176 bool GetVariableAsString(
const char *name,
STRING *val);
215 int Init(
const char* datapath,
const char* language,
OcrEngineMode mode,
216 char **configs,
int configs_size,
219 bool set_only_non_debug_params);
221 return Init(datapath, language, oem,
nullptr, 0,
nullptr,
nullptr,
false);
223 int Init(
const char* datapath,
const char* language) {
224 return Init(datapath, language,
OEM_DEFAULT,
nullptr, 0,
nullptr,
nullptr,
false);
228 int Init(
const char* data,
int data_size,
const char* language,
232 bool set_only_non_debug_params,
FileReader reader);
242 const char* GetInitLanguagesAsString()
const;
262 int InitLangMod(
const char* datapath,
const char* language);
268 void InitForAnalysePage();
276 void ReadConfigFile(
const char* filename);
278 void ReadDebugConfigFile(
const char* filename);
307 char* TesseractRect(
const unsigned char* imagedata,
308 int bytes_per_pixel,
int bytes_per_line,
309 int left,
int top,
int width,
int height);
315 void ClearAdaptiveClassifier();
332 void SetImage(
const unsigned char* imagedata,
int width,
int height,
333 int bytes_per_pixel,
int bytes_per_line);
343 void SetImage(Pix* pix);
349 void SetSourceResolution(
int ppi);
356 void SetRectangle(
int left,
int top,
int width,
int height);
367 thresholder_ = thresholder;
376 Pix* GetThresholdedImage();
383 Boxa* GetRegions(Pixa** pixa);
396 Boxa* GetTextlines(
bool raw_image,
int raw_padding,
397 Pixa** pixa,
int** blockids,
int** paraids);
402 return GetTextlines(
false, 0, pixa, blockids,
nullptr);
413 Boxa* GetStrips(Pixa** pixa,
int** blockids);
420 Boxa* GetWords(Pixa** pixa);
430 Boxa* GetConnectedComponents(Pixa** cc);
446 bool text_only,
bool raw_image,
448 Pixa** pixa,
int** blockids,
int** paraids);
451 const bool text_only,
452 Pixa** pixa,
int** blockids) {
453 return GetComponentImages(level, text_only,
false, 0, pixa, blockids,
nullptr);
462 int GetThresholdedImageScaleFactor()
const;
495 #ifndef DISABLED_LEGACY_ENGINE
497 int RecognizeForChopTest(
ETEXT_DESC* monitor);
522 bool ProcessPages(
const char* filename,
const char* retry_config,
525 bool ProcessPagesInternal(
const char* filename,
const char* retry_config,
537 bool ProcessPage(Pix* pix,
int page_index,
const char* filename,
538 const char* retry_config,
int timeout_millisec,
576 char* GetHOCRText(
ETEXT_DESC* monitor,
int page_number);
584 char* GetHOCRText(
int page_number);
590 char* GetAltoText(
ETEXT_DESC* monitor,
int page_number);
597 char* GetAltoText(
int page_number);
604 char* GetTSVText(
int page_number);
612 char* GetLSTMBoxText(
int page_number);
621 char* GetBoxText(
int page_number);
629 char* GetWordStrBoxText(
int page_number);
647 bool DetectOrientationScript(
int* orient_deg,
float* orient_conf,
648 const char** script_name,
float* script_conf);
655 char* GetOsdText(
int page_number);
665 int* AllWordConfidences();
667 #ifndef DISABLED_LEGACY_ENGINE
678 bool AdaptToWordStr(
PageSegMode mode,
const char* wordstr);
679 #endif // ndef DISABLED_LEGACY_ENGINE
704 static void ClearPersistentCache();
712 int IsValidWord(
const char *word);
714 bool IsValidCharacter(
const char *utf8_character);
717 bool GetTextDirection(
int* out_offset,
float* out_slope);
737 void GetBlockTextOrientations(
int** block_orientation,
738 bool** vertical_writing);
741 #ifndef DISABLED_LEGACY_ENGINE
747 BLOCK_LIST* FindLinesCreateBlockList();
754 static void DeleteBlockList(BLOCK_LIST* block_list);
757 static ROW *MakeTessOCRRow(
float baseline,
float xheight,
758 float descender,
float ascender);
761 static TBLOB *MakeTBLOB(Pix *pix);
768 static void NormalizeTBLOB(
TBLOB *tblob,
ROW *row,
bool numeric_mode);
772 int* num_features,
int* feature_outline_index);
778 static ROW* FindRowForBox(BLOCK_LIST* blocks,
int left,
int top,
779 int right,
int bottom);
785 void RunAdaptiveClassifier(
TBLOB* blob,
789 int* num_matches_returned);
790 #endif // ndef DISABLED_LEGACY_ENGINE
793 const char* GetUnichar(
int unichar_id);
796 const Dawg *GetDawg(
int i)
const;
799 int NumDawgs()
const;
807 void set_min_orientation_margin(
double margin);
848 #ifndef DISABLED_LEGACY_ENGINE
857 TESS_LOCAL void AdaptToCharacter(
const char *unichar_repr,
874 TESS_LOCAL static int TesseractExtractResult(
char** text,
885 #endif // ndef DISABLED_LEGACY_ENGINE
919 bool ProcessPagesFileList(FILE *fp,
921 const char* retry_config,
int timeout_millisec,
923 int tessedit_page_number);
925 bool ProcessPagesMultipageTiff(
const unsigned char *data,
927 const char* filename,
928 const char* retry_config,
929 int timeout_millisec,
931 int tessedit_page_number);
937 const char *unknown_title_ =
"";
944 #endif // TESSERACT_API_BASEAPI_H_
BLOCK_LIST * block_list_
The page layout.
void(Wordrec::*)(const MATRIX &, const WERD_CHOICE_LIST &, const UNICHARSET &, BlamerBundle *) FillLatticeFunc
GenericVector< ParagraphModel * > * paragraph_models_
FileReader reader_
Reads files from any filesystem.
OcrEngineMode last_oem_requested_
Last ocr language mode requested.
TESS_LOCAL const PAGE_RES * GetPageRes() const
struct TessBaseAPI TessBaseAPI
STRING * output_file_
Name used by debug code.
bool recognition_done_
page_res_ contains recognition data.
Tesseract * tesseract_
The underlying data object.
Tesseract * tesseract() const
PAGE_RES * page_res_
The page-level data.
OcrEngineMode oem() const
EquationDetect * equ_detect_
The equation detector.
TessCallback4< const UNICHARSET &, int, PageIterator *, Pix * > TruthCallback
int Init(const char *datapath, const char *language)
TruthCallback * truth_cb_
Boxa * GetTextlines(Pixa **pixa, int **blockids)
struct TessResultRenderer TessResultRenderer
STRING * datapath_
Current location of tessdata.
bool(*)(const STRING &, GenericVector< char > *) FileReader
void SetThresholder(ImageThresholder *thresholder)
STRING * input_file_
Name used by training code.
ImageThresholder * thresholder_
Image thresholding module.
int Init(const char *datapath, const char *language, OcrEngineMode oem)
STRING * language_
Last initialized language.
int(Dict::*)(void *, const UNICHARSET &, UNICHAR_ID, bool) const DictFunc
float(Dict::*)(const char *, void *) ParamsModelClassifyFunc
Tesseract * osd_tesseract_
For orientation & script detection.
Boxa * GetComponentImages(const PageIteratorLevel level, const bool text_only, Pixa **pixa, int **blockids)
void DetectParagraphs(int debug_level, GenericVector< RowInfo > *row_infos, GenericVector< PARA * > *row_owners, PARA_LIST *paragraphs, GenericVector< ParagraphModel * > *models)
void InitTruthCallback(TruthCallback *cb)
double(Dict::*)(const char *, const char *, int, const char *, int) ProbabilityInContextFunc
STRING HOcrEscape(const char *text)