tesseract
5.0.0-alpha-619-ge9db
|
Go to the documentation of this file.
19 #ifndef TESSERACT_API_BASEAPI_H_
20 #define TESSERACT_API_BASEAPI_H_
28 #include <tesseract/version.h>
59 class WERD_CHOICE_LIST;
85 const WERD_CHOICE_LIST&,
109 static const char* Version();
118 static size_t getOpenCLDevice(
void** device);
124 void SetInputName(
const char* name);
132 const char* GetInputName();
134 void SetInputImage(Pix* pix);
135 Pix* GetInputImage();
136 int GetSourceYResolution();
137 const char* GetDatapath();
140 void SetOutputName(
const char* name);
155 bool SetVariable(
const char* name,
const char* value);
156 bool SetDebugVariable(
const char* name,
const char* value);
162 bool GetIntVariable(
const char* name,
int* value)
const;
163 bool GetBoolVariable(
const char* name,
bool* value)
const;
164 bool GetDoubleVariable(
const char* name,
double* value)
const;
170 const char* GetStringVariable(
const char* name)
const;
175 void PrintVariables(FILE* fp)
const;
180 bool GetVariableAsString(
const char* name,
STRING* val);
219 int Init(
const char* datapath,
const char* language,
OcrEngineMode mode,
220 char** configs,
int configs_size,
223 bool set_only_non_debug_params);
225 return Init(datapath, language, oem,
nullptr, 0,
nullptr,
nullptr,
false);
227 int Init(
const char* datapath,
const char* language) {
228 return Init(datapath, language,
OEM_DEFAULT,
nullptr, 0,
nullptr,
nullptr,
233 int Init(
const char* data,
int data_size,
const char* language,
237 bool set_only_non_debug_params,
FileReader reader);
247 const char* GetInitLanguagesAsString()
const;
267 int InitLangMod(
const char* datapath,
const char* language);
273 void InitForAnalysePage();
281 void ReadConfigFile(
const char* filename);
283 void ReadDebugConfigFile(
const char* filename);
312 char* TesseractRect(
const unsigned char* imagedata,
int bytes_per_pixel,
313 int bytes_per_line,
int left,
int top,
int width,
320 void ClearAdaptiveClassifier();
337 void SetImage(
const unsigned char* imagedata,
int width,
int height,
338 int bytes_per_pixel,
int bytes_per_line);
348 void SetImage(Pix* pix);
354 void SetSourceResolution(
int ppi);
361 void SetRectangle(
int left,
int top,
int width,
int height);
372 thresholder_ = thresholder;
381 Pix* GetThresholdedImage();
388 Boxa* GetRegions(Pixa** pixa);
401 Boxa* GetTextlines(
bool raw_image,
int raw_padding, Pixa** pixa,
402 int** blockids,
int** paraids);
407 return GetTextlines(
false, 0, pixa, blockids,
nullptr);
418 Boxa* GetStrips(Pixa** pixa,
int** blockids);
425 Boxa* GetWords(Pixa** pixa);
435 Boxa* GetConnectedComponents(Pixa** cc);
450 bool raw_image,
int raw_padding, Pixa** pixa,
451 int** blockids,
int** paraids);
454 Pixa** pixa,
int** blockids) {
455 return GetComponentImages(level, text_only,
false, 0, pixa, blockids,
465 int GetThresholdedImageScaleFactor()
const;
498 #ifndef DISABLED_LEGACY_ENGINE
500 int RecognizeForChopTest(
ETEXT_DESC* monitor);
525 bool ProcessPages(
const char* filename,
const char* retry_config,
528 bool ProcessPagesInternal(
const char* filename,
const char* retry_config,
540 bool ProcessPage(Pix* pix,
int page_index,
const char* filename,
541 const char* retry_config,
int timeout_millisec,
579 char* GetHOCRText(
ETEXT_DESC* monitor,
int page_number);
587 char* GetHOCRText(
int page_number);
593 char* GetAltoText(
ETEXT_DESC* monitor,
int page_number);
599 char* GetAltoText(
int page_number);
606 char* GetTSVText(
int page_number);
614 char* GetLSTMBoxText(
int page_number);
623 char* GetBoxText(
int page_number);
631 char* GetWordStrBoxText(
int page_number);
649 bool DetectOrientationScript(
int* orient_deg,
float* orient_conf,
650 const char** script_name,
float* script_conf);
657 char* GetOsdText(
int page_number);
667 int* AllWordConfidences();
669 #ifndef DISABLED_LEGACY_ENGINE
680 bool AdaptToWordStr(
PageSegMode mode,
const char* wordstr);
681 #endif // ndef DISABLED_LEGACY_ENGINE
706 static void ClearPersistentCache();
714 int IsValidWord(
const char* word);
716 bool IsValidCharacter(
const char* utf8_character);
718 bool GetTextDirection(
int* out_offset,
float* out_slope);
738 void GetBlockTextOrientations(
int** block_orientation,
739 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,
float descender,
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,
int right,
785 void RunAdaptiveClassifier(
TBLOB* blob,
int num_max_matches,
int* unichar_ids,
786 float* ratings,
int* num_matches_returned);
787 #endif // ndef DISABLED_LEGACY_ENGINE
790 const char* GetUnichar(
int unichar_id);
793 const Dawg* GetDawg(
int i)
const;
796 int NumDawgs()
const;
803 return last_oem_requested_;
810 void set_min_orientation_margin(
double margin);
851 #ifndef DISABLED_LEGACY_ENGINE
860 TESS_LOCAL void AdaptToCharacter(
const char* unichar_repr,
int length,
862 float descender,
float ascender);
874 TESS_LOCAL static int TesseractExtractResult(
char** text,
int** lengths,
875 float** costs,
int** x0,
876 int** y0,
int** x1,
int** y1,
883 #endif // ndef DISABLED_LEGACY_ENGINE
917 bool ProcessPagesFileList(FILE* fp,
STRING* buf,
const char* retry_config,
919 int tessedit_page_number);
921 bool ProcessPagesMultipageTiff(
const unsigned char* data,
size_t size,
922 const char* filename,
const char* retry_config,
923 int timeout_millisec,
925 int tessedit_page_number);
932 #endif // TESSERACT_API_BASEAPI_H_
int Init(const char *datapath, const char *language, OcrEngineMode oem)
PAGE_RES * page_res_
The page-level data.
OcrEngineMode last_oem_requested_
Last ocr language mode requested.
int(Dict::*)(void *, const UNICHARSET &, UNICHAR_ID, bool) const DictFunc
GenericVector< ParagraphModel * > * paragraph_models_
void SetThresholder(ImageThresholder *thresholder)
int Init(const char *datapath, const char *language)
BLOCK_LIST * block_list_
The page layout.
bool(*)(const char *filename, GenericVector< char > *data) FileReader
const TESS_LOCAL PAGE_RES * GetPageRes() const
double(Dict::*)(const char *, const char *, int, const char *, int) ProbabilityInContextFunc
void InitTruthCallback(TruthCallback cb)
float(Dict::*)(const char *, void *) ParamsModelClassifyFunc
TruthCallback truth_cb_
fxn for setting truth_* in WERD_RES
EquationDetect * equ_detect_
The equation detector.
Tesseract * osd_tesseract_
For orientation & script detection.
Tesseract * tesseract_
The underlying data object.
STRING * input_file_
Name used by training code.
bool recognition_done_
page_res_ contains recognition data.
ImageThresholder * thresholder_
Image thresholding module.
FileReader reader_
Reads files from any filesystem.
Boxa * GetComponentImages(const PageIteratorLevel level, const bool text_only, Pixa **pixa, int **blockids)
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)
struct TessBaseAPI TessBaseAPI
STRING * datapath_
Current location of tessdata.
Tesseract * tesseract() const
std::function< void(const UNICHARSET &, int, PageIterator *, Pix *)> TruthCallback
OcrEngineMode oem() const
void(Wordrec::*)(const MATRIX &, const WERD_CHOICE_LIST &, const UNICHARSET &, BlamerBundle *) FillLatticeFunc
STRING * output_file_
Name used by debug code.
STRING * language_
Last initialized language.
STRING HOcrEscape(const char *text)