20 #ifndef TESSERACT_API_BASEAPI_H_ 21 #define TESSERACT_API_BASEAPI_H_ 23 #define TESSERACT_VERSION_STR "4.00.00alpha" 24 #define TESSERACT_VERSION 0x040000 25 #define MAKE_VERSION(major, minor, patch) (((major) << 16) | ((minor) << 8) | \ 61 class WERD_CHOICE_LIST;
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();
144 void SetInputImage(Pix *pix);
145 Pix* GetInputImage();
146 int GetSourceYResolution();
147 const char* GetDatapath();
150 void SetOutputName(
const char* name);
165 bool SetVariable(
const char* name,
const char* value);
166 bool SetDebugVariable(
const char* name,
const char* value);
172 bool GetIntVariable(
const char *name,
int *value)
const;
173 bool GetBoolVariable(
const char *name,
bool *value)
const;
174 bool GetDoubleVariable(
const char *name,
double *value)
const;
180 const char *GetStringVariable(
const char *name)
const;
185 void PrintVariables(FILE *fp)
const;
190 bool GetVariableAsString(
const char *name,
STRING *val);
231 char **configs,
int configs_size,
234 bool set_only_non_debug_params);
236 return Init(datapath, language, oem, NULL, 0, NULL, NULL,
false);
238 int Init(
const char* datapath,
const char* language) {
239 return Init(datapath, language,
OEM_DEFAULT, NULL, 0, NULL, NULL,
false);
243 int Init(
const char* data,
int data_size,
const char* language,
247 bool set_only_non_debug_params,
FileReader reader);
257 const char* GetInitLanguagesAsString()
const;
277 int InitLangMod(
const char* datapath,
const char* language);
283 void InitForAnalysePage();
291 void ReadConfigFile(
const char*
filename);
293 void ReadDebugConfigFile(
const char* filename);
322 char* TesseractRect(
const unsigned char* imagedata,
323 int bytes_per_pixel,
int bytes_per_line,
324 int left,
int top,
int width,
int height);
330 void ClearAdaptiveClassifier();
347 void SetImage(
const unsigned char* imagedata,
int width,
int height,
348 int bytes_per_pixel,
int bytes_per_line);
358 void SetImage(Pix* pix);
364 void SetSourceResolution(
int ppi);
371 void SetRectangle(
int left,
int top,
int width,
int height);
382 thresholder_ = thresholder;
391 Pix* GetThresholdedImage();
398 Boxa* GetRegions(Pixa** pixa);
411 Boxa* GetTextlines(
const bool raw_image,
const int raw_padding,
412 Pixa** pixa,
int** blockids,
int** paraids);
417 return GetTextlines(
false, 0, pixa, blockids, NULL);
428 Boxa* GetStrips(Pixa** pixa,
int** blockids);
435 Boxa* GetWords(Pixa** pixa);
445 Boxa* GetConnectedComponents(Pixa** cc);
461 const bool text_only,
const bool raw_image,
462 const int raw_padding,
463 Pixa** pixa,
int** blockids,
int** paraids);
466 const bool text_only,
467 Pixa** pixa,
int** blockids) {
468 return GetComponentImages(level, text_only,
false, 0, pixa, blockids, NULL);
477 int GetThresholdedImageScaleFactor()
const;
484 void DumpPGM(
const char* filename);
518 int RecognizeForChopTest(
ETEXT_DESC* monitor);
542 bool ProcessPages(
const char* filename,
const char* retry_config,
545 bool ProcessPagesInternal(
const char* filename,
const char* retry_config,
557 bool ProcessPage(Pix* pix,
int page_index,
const char* filename,
558 const char* retry_config,
int timeout_millisec,
596 char* GetHOCRText(
ETEXT_DESC* monitor,
int page_number);
604 char* GetHOCRText(
int page_number);
611 char* GetTSVText(
int page_number);
620 char* GetBoxText(
int page_number);
638 bool DetectOrientationScript(
int* orient_deg,
float* orient_conf,
639 const char** script_name,
float* script_conf);
646 char* GetOsdText(
int page_number);
656 int* AllWordConfidences();
668 bool AdaptToWordStr(
PageSegMode mode,
const char* wordstr);
693 static void ClearPersistentCache();
701 int IsValidWord(
const char *word);
703 bool IsValidCharacter(
const char *utf8_character);
706 bool GetTextDirection(
int* out_offset,
float* out_slope);
727 int* num_features,
int* feature_outline_index);
733 static ROW* FindRowForBox(BLOCK_LIST* blocks,
int left,
int top,
734 int right,
int bottom);
740 void RunAdaptiveClassifier(
TBLOB* blob,
744 int* num_matches_returned);
747 const char* GetUnichar(
int unichar_id);
750 const Dawg *GetDawg(
int i)
const;
753 int NumDawgs()
const;
756 static ROW *MakeTessOCRRow(
float baseline,
float xheight,
757 float descender,
float ascender);
760 static TBLOB *MakeTBLOB(Pix *pix);
767 static void NormalizeTBLOB(
TBLOB *tblob,
ROW *row,
bool numeric_mode);
775 void set_min_orientation_margin(
double margin);
781 void GetBlockTextOrientations(
int** block_orientation,
782 bool** vertical_writing);
785 BLOCK_LIST* FindLinesCreateBlockList();
792 static void DeleteBlockList(BLOCK_LIST* block_list);
837 TESS_LOCAL void AdaptToCharacter(
const char *unichar_repr,
856 TESS_LOCAL static int TesseractExtractResult(
char** text,
901 bool ProcessPagesFileList(FILE *fp,
903 const char* retry_config,
int timeout_millisec,
905 int tessedit_page_number);
907 bool ProcessPagesMultipageTiff(
const unsigned char *data,
909 const char* filename,
910 const char* retry_config,
911 int timeout_millisec,
913 int tessedit_page_number);
919 const char *unknown_title_ =
"";
926 #endif // TESSERACT_API_BASEAPI_H_ STRING * input_file_
Name used by training code.
void DetectParagraphs(int debug_level, GenericVector< RowInfo > *row_infos, GenericVector< PARA *> *row_owners, PARA_LIST *paragraphs, GenericVector< ParagraphModel *> *models)
float(Dict::* ParamsModelClassifyFunc)(const char *lang, void *path)
FileReader reader_
Reads files from any filesystem.
void(Wordrec::* FillLatticeFunc)(const MATRIX &ratings, const WERD_CHOICE_LIST &best_choices, const UNICHARSET &unicharset, BlamerBundle *blamer_bundle)
bool(* FileReader)(const STRING &filename, GenericVector< char > *data)
STRING * output_file_
Name used by debug code.
BLOCK_LIST * block_list_
The page layout.
struct TessBaseAPI TessBaseAPI
int Init(const char *datapath, const char *language, OcrEngineMode oem)
void InitTruthCallback(TruthCallback *cb)
ImageThresholder * thresholder_
Image thresholding module.
PAGE_RES * page_res_
The page-level data.
OcrEngineMode last_oem_requested_
Last ocr language mode requested.
Tesseract * tesseract_
The underlying data object.
INT_FEATURE_STRUCT * INT_FEATURE
TruthCallback * truth_cb_
TESS_LOCAL const PAGE_RES * GetPageRes() const
EquationDetect * equ_detect_
The equation detector.
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)
TessCallback4< const UNICHARSET &, int, PageIterator *, Pix * > TruthCallback
Tesseract * tesseract() const
OcrEngineMode oem() const
void SetThresholder(ImageThresholder *thresholder)
STRING * language_
Last initialized language.
STRING HOcrEscape(const char *text)
Tesseract * osd_tesseract_
For orientation & script detection.
int(Dict::* DictFunc)(void *void_dawg_args, UNICHAR_ID unichar_id, bool word_end) const
STRING * datapath_
Current location of tessdata.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
struct TessResultRenderer TessResultRenderer
bool recognition_done_
page_res_ contains recognition data.
Boxa * GetTextlines(Pixa **pixa, int **blockids)
GenericVector< ParagraphModel * > * paragraph_models_
Boxa * GetComponentImages(const PageIteratorLevel level, const bool text_only, Pixa **pixa, int **blockids)