20 #ifndef TESSERACT_API_BASEAPI_H__ 21 #define TESSERACT_API_BASEAPI_H__ 23 #define TESSERACT_VERSION_STR "3.05.02" 24 #define TESSERACT_VERSION 0x030502 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();
146 void SetInputImage(Pix *pix);
147 Pix* GetInputImage();
148 int GetSourceYResolution();
149 const char* GetDatapath();
152 void SetOutputName(
const char* name);
167 bool SetVariable(
const char* name,
const char* value);
168 bool SetDebugVariable(
const char* name,
const char* value);
174 bool GetIntVariable(
const char *name,
int *value)
const;
175 bool GetBoolVariable(
const char *name,
bool *value)
const;
176 bool GetDoubleVariable(
const char *name,
double *value)
const;
182 const char *GetStringVariable(
const char *name)
const;
187 void PrintVariables(FILE *fp)
const;
192 bool GetVariableAsString(
const char *name,
STRING *val);
233 char **configs,
int configs_size,
236 bool set_only_non_debug_params);
238 return Init(datapath, language, oem, NULL, 0, NULL, NULL,
false);
240 int Init(
const char* datapath,
const char* language) {
241 return Init(datapath, language,
OEM_DEFAULT, NULL, 0, NULL, NULL,
false);
252 const char* GetInitLanguagesAsString()
const;
272 int InitLangMod(
const char* datapath,
const char* language);
278 void InitForAnalysePage();
286 void ReadConfigFile(
const char*
filename);
288 void ReadDebugConfigFile(
const char*
filename);
317 char* TesseractRect(
const unsigned char* imagedata,
318 int bytes_per_pixel,
int bytes_per_line,
319 int left,
int top,
int width,
int height);
325 void ClearAdaptiveClassifier();
342 void SetImage(
const unsigned char* imagedata,
int width,
int height,
343 int bytes_per_pixel,
int bytes_per_line);
353 void SetImage(Pix* pix);
359 void SetSourceResolution(
int ppi);
366 void SetRectangle(
int left,
int top,
int width,
int height);
377 thresholder_ = thresholder;
386 Pix* GetThresholdedImage();
393 Boxa* GetRegions(Pixa** pixa);
406 Boxa* GetTextlines(
const bool raw_image,
const int raw_padding,
407 Pixa** pixa,
int** blockids,
int** paraids);
412 return GetTextlines(
false, 0, pixa, blockids, NULL);
423 Boxa* GetStrips(Pixa** pixa,
int** blockids);
430 Boxa* GetWords(Pixa** pixa);
440 Boxa* GetConnectedComponents(Pixa** cc);
456 const bool text_only,
const bool raw_image,
457 const int raw_padding,
458 Pixa** pixa,
int** blockids,
int** paraids);
461 const bool text_only,
462 Pixa** pixa,
int** blockids) {
463 return GetComponentImages(level, text_only,
false, 0, pixa, blockids, NULL);
472 int GetThresholdedImageScaleFactor()
const;
513 int RecognizeForChopTest(
ETEXT_DESC* monitor);
537 bool ProcessPages(
const char*
filename,
const char* retry_config,
540 bool ProcessPagesInternal(
const char*
filename,
const char* retry_config,
552 bool ProcessPage(Pix* pix,
int page_index,
const char*
filename,
553 const char* retry_config,
int timeout_millisec,
590 char* GetHOCRText(
ETEXT_DESC* monitor,
int page_number);
597 char* GetHOCRText(
int page_number);
603 char* GetTSVText(
int page_number);
612 char* GetBoxText(
int page_number);
629 bool DetectOrientationScript(
int* orient_deg,
float* orient_conf,
const char** script_name,
float* script_conf);
636 char* GetOsdText(
int page_number);
646 int* AllWordConfidences();
683 static void ClearPersistentCache();
691 int IsValidWord(
const char *word);
693 bool IsValidCharacter(
const char *utf8_character);
696 bool GetTextDirection(
int* out_offset,
float* out_slope);
717 int* num_features,
int* feature_outline_index);
723 static ROW* FindRowForBox(BLOCK_LIST* blocks,
int left,
int top,
724 int right,
int bottom);
730 void RunAdaptiveClassifier(
TBLOB* blob,
734 int* num_matches_returned);
737 const char* GetUnichar(
int unichar_id);
740 const Dawg *GetDawg(
int i)
const;
743 int NumDawgs()
const;
746 static ROW *MakeTessOCRRow(
float baseline,
float xheight,
747 float descender,
float ascender);
750 static TBLOB *MakeTBLOB(Pix *pix);
757 static void NormalizeTBLOB(
TBLOB *tblob,
ROW *row,
bool numeric_mode);
765 #ifndef NO_CUBE_BUILD 768 #endif // NO_CUBE_BUILD 770 void set_min_orientation_margin(
double margin);
776 void GetBlockTextOrientations(
int** block_orientation,
777 bool** vertical_writing);
780 BLOCK_LIST* FindLinesCreateBlockList();
787 static void DeleteBlockList(BLOCK_LIST* block_list);
832 TESS_LOCAL void AdaptToCharacter(
const char *unichar_repr,
851 TESS_LOCAL static int TesseractExtractResult(
char** text,
895 bool ProcessPagesFileList(FILE *fp,
897 const char* retry_config,
int timeout_millisec,
899 int tessedit_page_number);
901 bool ProcessPagesMultipageTiff(
const unsigned char *data,
904 const char* retry_config,
905 int timeout_millisec,
907 int tessedit_page_number);
913 const char *unknown_title_;
920 #endif // TESSERACT_API_BASEAPI_H__
void SetThresholder(ImageThresholder *thresholder)
Boxa * GetTextlines(Pixa **pixa, int **blockids)
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.
struct TessBaseAPI TessBaseAPI
TESS_LOCAL const PAGE_RES * GetPageRes() const
int Init(const char *datapath, const char *language, OcrEngineMode oem)
TessCallback4< const UNICHARSET &, int, PageIterator *, Pix * > TruthCallback
PAGE_RES * page_res_
The page-level data.
void InitTruthCallback(TruthCallback *cb)
INT_FEATURE_STRUCT * INT_FEATURE
OcrEngineMode oem() const
Tesseract * osd_tesseract_
For orientation & script detection.
float(Dict::* ParamsModelClassifyFunc)(const char *lang, void *path)
int(Dict::* DictFunc)(void *void_dawg_args, UNICHAR_ID unichar_id, bool word_end) const
double(Dict::* ProbabilityInContextFunc)(const char *lang, const char *context, int context_bytes, const char *character, int character_bytes)
int Init(const char *datapath, const char *language)
GenericVector< ParagraphModel * > * paragraph_models_
EquationDetect * equ_detect_
The equation detector.
bool recognition_done_
page_res_ contains recognition data.
void(Wordrec::* FillLatticeFunc)(const MATRIX &ratings, const WERD_CHOICE_LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)
TruthCallback * truth_cb_
STRING * language_
Last initialized language.
STRING HOcrEscape(const char *text)
ImageThresholder * thresholder_
Image thresholding module.
struct TessResultRenderer TessResultRenderer
Tesseract * tesseract() const
Tesseract * tesseract_
The underlying data object.
OcrEngineMode last_oem_requested_
Last ocr language mode requested.
STRING * input_file_
Name used by training code.
Boxa * GetComponentImages(const PageIteratorLevel level, const bool text_only, Pixa **pixa, int **blockids)
BLOCK_LIST * block_list_
The page layout.
STRING * datapath_
Current location of tessdata.