20 #ifndef TESSERACT_API_BASEAPI_H__
21 #define TESSERACT_API_BASEAPI_H__
23 #define TESSERACT_VERSION_STR "3.04.01"
24 #define TESSERACT_VERSION 0x030401
25 #define MAKE_VERSION(major, minor, patch) (((major) << 16) | ((minor) << 8) | \
60 class WERD_CHOICE_LIST;
69 class CubeRecoContext;
70 #endif // NO_CUBE_BUILD
75 class LTRResultIterator;
77 class MutableIterator;
91 const char *
lang,
void *path);
93 const WERD_CHOICE_LIST &best_choices,
115 static const char* Version();
124 static size_t getOpenCLDevice(
void **device);
130 static void CatchSignals();
136 void SetInputName(
const char*
name);
144 const char* GetInputName();
145 void SetInputImage(Pix *pix);
146 Pix* GetInputImage();
147 int GetSourceYResolution();
148 const char* GetDatapath();
151 void SetOutputName(
const char* name);
166 bool SetVariable(
const char* name,
const char* value);
167 bool SetDebugVariable(
const char* name,
const char* value);
173 bool GetIntVariable(
const char *name,
int *value)
const;
174 bool GetBoolVariable(
const char *name,
bool *value)
const;
175 bool GetDoubleVariable(
const char *name,
double *value)
const;
181 const char *GetStringVariable(
const char *name)
const;
186 void PrintVariables(FILE *fp)
const;
191 bool GetVariableAsString(
const char *name,
STRING *val);
232 char **configs,
int configs_size,
235 bool set_only_non_debug_params);
237 return Init(datapath, language, oem, NULL, 0, NULL, NULL,
false);
239 int Init(
const char* datapath,
const char* language) {
240 return Init(datapath, language,
OEM_DEFAULT, NULL, 0, NULL, NULL,
false);
251 const char* GetInitLanguagesAsString()
const;
271 int InitLangMod(
const char* datapath,
const char* language);
277 void InitForAnalysePage();
285 void ReadConfigFile(
const char*
filename);
287 void ReadDebugConfigFile(
const char*
filename);
316 char* TesseractRect(
const unsigned char* imagedata,
317 int bytes_per_pixel,
int bytes_per_line,
318 int left,
int top,
int width,
int height);
324 void ClearAdaptiveClassifier();
343 void SetImage(
const unsigned char* imagedata,
int width,
int height,
344 int bytes_per_pixel,
int bytes_per_line);
356 void SetImage(Pix* pix);
362 void SetSourceResolution(
int ppi);
369 void SetRectangle(
int left,
int top,
int width,
int height);
379 if (thresholder_ != NULL)
381 thresholder_ = thresholder;
390 Pix* GetThresholdedImage();
397 Boxa* GetRegions(Pixa** pixa);
410 Boxa* GetTextlines(
const bool raw_image,
const int raw_padding,
411 Pixa** pixa,
int** blockids,
int** paraids);
416 return GetTextlines(
false, 0, pixa, blockids, NULL);
427 Boxa* GetStrips(Pixa** pixa,
int** blockids);
434 Boxa* GetWords(Pixa** pixa);
444 Boxa* GetConnectedComponents(Pixa** cc);
460 const bool text_only,
const bool raw_image,
461 const int raw_padding,
462 Pixa** pixa,
int** blockids,
int** paraids);
465 const bool text_only,
466 Pixa** pixa,
int** blockids) {
467 return GetComponentImages(level, text_only,
false, 0, pixa, blockids, NULL);
476 int GetThresholdedImageScaleFactor()
const;
501 return AnalyseLayout(
false);
519 int RecognizeForChopTest(
ETEXT_DESC* monitor);
543 bool ProcessPages(
const char*
filename,
const char* retry_config,
546 bool ProcessPagesInternal(
const char*
filename,
const char* retry_config,
558 bool ProcessPage(Pix* pix,
int page_index,
const char*
filename,
559 const char* retry_config,
int timeout_millisec,
593 char* GetHOCRText(
int page_number);
602 char* GetBoxText(
int page_number);
616 char* GetOsdText(
int page_number);
626 int* AllWordConfidences();
638 bool AdaptToWordStr(
PageSegMode mode,
const char* wordstr);
663 static void ClearPersistentCache();
671 int IsValidWord(
const char *word);
673 bool IsValidCharacter(
const char *utf8_character);
676 bool GetTextDirection(
int* out_offset,
float* out_slope);
697 int* num_features,
int* feature_outline_index);
703 static ROW* FindRowForBox(BLOCK_LIST* blocks,
int left,
int top,
704 int right,
int bottom);
710 void RunAdaptiveClassifier(
TBLOB* blob,
714 int* num_matches_returned);
717 const char* GetUnichar(
int unichar_id);
720 const Dawg *GetDawg(
int i)
const;
723 int NumDawgs()
const;
726 static ROW *MakeTessOCRRow(
float baseline,
float xheight,
727 float descender,
float ascender);
730 static TBLOB *MakeTBLOB(Pix *pix);
737 static void NormalizeTBLOB(
TBLOB *tblob,
ROW *row,
bool numeric_mode);
744 return last_oem_requested_;
749 #ifndef NO_CUBE_BUILD
752 #endif // NO_CUBE_BUILD
754 void set_min_orientation_margin(
double margin);
760 void GetBlockTextOrientations(
int** block_orientation,
761 bool** vertical_writing);
764 BLOCK_LIST* FindLinesCreateBlockList();
771 static void DeleteBlockList(BLOCK_LIST* block_list);
816 TESS_LOCAL void AdaptToCharacter(
const char *unichar_repr,
835 TESS_LOCAL static int TesseractExtractResult(
char** text,
882 bool ProcessPagesFileList(FILE *fp,
884 const char* retry_config,
int timeout_millisec,
886 int tessedit_page_number);
888 bool ProcessPagesMultipageTiff(
const unsigned char *data,
891 const char* retry_config,
892 int timeout_millisec,
894 int tessedit_page_number);
901 #endif // TESSERACT_API_BASEAPI_H__
Boxa * GetComponentImages(const PageIteratorLevel level, const bool text_only, Pixa **pixa, int **blockids)
EquationDetect * equ_detect_
The equation detector.
int Init(const char *datapath, const char *language, OcrEngineMode oem)
OcrEngineMode last_oem_requested_
Last ocr language mode requested.
float(Dict::* ParamsModelClassifyFunc)(const char *lang, void *path)
TruthCallback * truth_cb_
PageIterator * AnalyseLayout()
void InitTruthCallback(TruthCallback *cb)
GenericVector< ParagraphModel * > * paragraph_models_
Boxa * GetTextlines(Pixa **pixa, int **blockids)
ImageThresholder * thresholder_
Image thresholding module.
Pix * input_image_
Image used for searchable PDF.
STRING * language_
Last initialized language.
OcrEngineMode oem() const
Tesseract * tesseract() const
TessCallback4< const UNICHARSET &, int, PageIterator *, Pix * > TruthCallback
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)
STRING * output_file_
Name used by debug code.
INT_FEATURE_STRUCT * INT_FEATURE
PAGE_RES * page_res_
The page-level data.
STRING * datapath_
Current location of tessdata.
void SetThresholder(ImageThresholder *thresholder)
TESS_LOCAL const PAGE_RES * GetPageRes() const
int(Dict::* DictFunc)(void *void_dawg_args, UNICHAR_ID unichar_id, bool word_end) const
struct TessResultRenderer TessResultRenderer
int Init(const char *datapath, const char *language)
void(Wordrec::* FillLatticeFunc)(const MATRIX &ratings, const WERD_CHOICE_LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)
Tesseract * osd_tesseract_
For orientation & script detection.
BLOCK_LIST * block_list_
The page layout.
STRING HOcrEscape(const char *text)
STRING * input_file_
Name used by training code.
bool recognition_done_
page_res_ contains recognition data.
struct TessBaseAPI TessBaseAPI