20 #ifndef TESSERACT_API_BASEAPI_H__
21 #define TESSERACT_API_BASEAPI_H__
63 #define MAX_NUM_INT_FEATURES 512
71 class CubeRecoContext;
75 class LTRResultIterator;
76 class MutableIterator;
89 const LIST &best_choices,
110 static const char* Version();
116 void SetInputName(
const char* name);
119 void SetOutputName(
const char* name);
136 bool SetVariable(
const char* name,
const char* value);
137 bool SetDebugVariable(
const char* name,
const char* value);
143 bool GetIntVariable(
const char *name,
int *value)
const;
144 bool GetBoolVariable(
const char *name,
bool *value)
const;
145 bool GetDoubleVariable(
const char *name,
double *value)
const;
151 const char *GetStringVariable(
const char *name)
const;
156 void PrintVariables(FILE *fp)
const;
161 bool GetVariableAsString(
const char *name,
STRING *val);
202 char **configs,
int configs_size,
205 bool set_only_non_debug_params);
207 return Init(datapath, language, oem,
NULL, 0,
NULL,
NULL,
false);
209 int Init(
const char* datapath,
const char* language) {
221 const char* GetInitLanguagesAsString()
const;
241 int InitLangMod(
const char* datapath,
const char* language);
247 void InitForAnalysePage();
255 void ReadConfigFile(
const char*
filename);
257 void ReadDebugConfigFile(
const char*
filename);
286 char* TesseractRect(
const unsigned char* imagedata,
287 int bytes_per_pixel,
int bytes_per_line,
288 int left,
int top,
int width,
int height);
294 void ClearAdaptiveClassifier();
313 void SetImage(
const unsigned char* imagedata,
int width,
int height,
314 int bytes_per_pixel,
int bytes_per_line);
326 void SetImage(
const Pix* pix);
332 void SetSourceResolution(
int ppi);
339 void SetRectangle(
int left,
int top,
int width,
int height);
349 if (thresholder_ !=
NULL)
351 thresholder_ = thresholder;
360 Pix* GetThresholdedImage();
367 Boxa* GetRegions(Pixa** pixa);
376 Boxa* GetTextlines(Pixa** pixa,
int** blockids);
386 Boxa* GetStrips(Pixa** pixa,
int** blockids);
393 Boxa* GetWords(Pixa** pixa);
403 Boxa* GetConnectedComponents(Pixa** cc);
415 Pixa** pixa,
int** blockids);
423 int GetThresholdedImageScaleFactor()
const;
459 int RecognizeForChopTest(
ETEXT_DESC* monitor);
477 bool ProcessPages(
const char*
filename,
478 const char* retry_config,
int timeout_millisec,
492 bool ProcessPage(Pix* pix,
int page_index,
const char*
filename,
493 const char* retry_config,
int timeout_millisec,
527 char* GetHOCRText(
int page_number);
535 char* GetBoxText(
int page_number);
550 int* AllWordConfidences();
562 bool AdaptToWordStr(
PageSegMode mode,
const char* wordstr);
586 int IsValidWord(
const char *word);
588 bool GetTextDirection(
int* out_offset,
float* out_slope);
608 void GetFeaturesForBlob(
TBLOB* blob,
const DENORM& denorm,
610 int* num_features,
int* FeatureOutlineIndex);
616 static ROW* FindRowForBox(BLOCK_LIST* blocks,
int left,
int top,
617 int right,
int bottom);
623 void RunAdaptiveClassifier(
TBLOB* blob,
const DENORM& denorm,
627 int* num_matches_returned);
630 const char* GetUnichar(
int unichar_id);
633 const Dawg *GetDawg(
int i)
const;
636 int NumDawgs()
const;
639 static ROW *MakeTessOCRRow(
float baseline,
float xheight,
640 float descender,
float ascender);
643 static TBLOB *MakeTBLOB(Pix *pix);
650 static void NormalizeTBLOB(
TBLOB *tblob,
ROW *row,
651 bool numeric_mode,
DENORM *denorm);
658 return last_oem_requested_;
666 void set_min_orientation_margin(
double margin);
672 void GetBlockTextOrientations(
int** block_orientation,
673 bool** vertical_writing);
676 BLOCK_LIST* FindLinesCreateBlockList();
683 static void DeleteBlockList(BLOCK_LIST* block_list);
728 TESS_LOCAL void AdaptToCharacter(
const char *unichar_repr,
746 TESS_LOCAL static int TesseractExtractResult(
char** text,
793 #endif // TESSERACT_API_BASEAPI_H__
int Init(const char *datapath, const char *language)
void InitTruthCallback(TruthCallback *cb)
BLOCK_LIST * block_list_
The page layout.
EquationDetect * equ_detect_
The equation detector.
void SetThresholder(ImageThresholder *thresholder)
ImageThresholder * thresholder_
Image thresholding module.
STRING * input_file_
Name used by training code.
TessCallback3< const UNICHARSET &, int, PAGE_RES * > TruthCallback
OcrEngineMode last_oem_requested_
Last ocr language mode requested.
STRING * datapath_
Current location of tessdata.
GenericVector< ParagraphModel * > * paragraph_models_
STRING * output_file_
Name used by debug code.
int Init(const char *datapath, const char *language, OcrEngineMode oem)
#define MAX_NUM_INT_FEATURES
TruthCallback * truth_cb_
OcrEngineMode const oem() const
int(Dict::* DictFunc)(void *void_dawg_args, UNICHAR_ID unichar_id, bool word_end) const
PAGE_RES * page_res_
The page-level data.
bool recognition_done_
page_res_ contains recognition data.
Tesseract * osd_tesseract_
For orientation & script detection.
double(Dict::* ProbabilityInContextFunc)(const char *lang, const char *context, int context_bytes, const char *character, int character_bytes)
TESS_LOCAL const PAGE_RES * GetPageRes() const
INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES]
struct TessBaseAPI TessBaseAPI
void DetectParagraphs(int debug_level, GenericVector< RowInfo > *row_infos, GenericVector< PARA * > *row_owners, PARA_LIST *paragraphs, GenericVector< ParagraphModel * > *models)
Tesseract *const tesseract() const
STRING * language_
Last initialized language.
void(Wordrec::* FillLatticeFunc)(const MATRIX &ratings, const LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)
INT_FEATURE_STRUCT * INT_FEATURE