tessbox.cpp
来自「一个google的OCR源码」· C++ 代码 · 共 376 行 · 第 1/2 页
CPP
376 行
) { TWERD *tessword; //converted word inT32 result; //answer tessword = make_tess_word (word, NULL); result = AdaptableWord (tessword, word_choice->string ().string (), word_choice->lengths ().string (), raw_choice->string ().string (), raw_choice->lengths ().string ()); delete_word(tessword); return result != 0;}/********************************************************************** * tess_cn_matcher * * Match a blob using the Tess Char Normalized (non-adaptive) matcher * only. **********************************************************************/void tess_cn_matcher( //call tess PBLOB *pblob, //previous blob PBLOB *blob, //blob to match PBLOB *nblob, //next blob WERD *word, //word it came from DENORM *denorm, //de-normaliser BLOB_CHOICE_LIST &ratings //list of results ) { LIST result; //tess output TBLOB *tessblob; //converted blob TEXTROW tessrow; //dummy row tess_cn_matching = TRUE; //turn it on tess_bn_matching = FALSE; //convert blob tessblob = make_tess_blob (blob, TRUE); //make dummy row make_tess_row(denorm, &tessrow); //classify result = AdaptiveClassifier (tessblob, NULL, &tessrow); free_blob(tessblob); //make our format convert_choice_list(result, ratings);}/********************************************************************** * tess_bn_matcher * * Match a blob using the Tess Baseline Normalized (adaptive) matcher * only. **********************************************************************/void tess_bn_matcher( //call tess PBLOB *pblob, //previous blob PBLOB *blob, //blob to match PBLOB *nblob, //next blob WERD *word, //word it came from DENORM *denorm, //de-normaliser BLOB_CHOICE_LIST &ratings //list of results ) { LIST result; //tess output TBLOB *tessblob; //converted blob TEXTROW tessrow; //dummy row tess_bn_matching = TRUE; //turn it on tess_cn_matching = FALSE; //convert blob tessblob = make_tess_blob (blob, TRUE); //make dummy row make_tess_row(denorm, &tessrow); //classify result = AdaptiveClassifier (tessblob, NULL, &tessrow); free_blob(tessblob); //make our format convert_choice_list(result, ratings);}/********************************************************************** * tess_default_matcher * * Match a blob using the default functionality of the Tess matcher. **********************************************************************/void tess_default_matcher( //call tess PBLOB *pblob, //previous blob PBLOB *blob, //blob to match PBLOB *nblob, //next blob WERD *word, //word it came from DENORM *denorm, //de-normaliser BLOB_CHOICE_LIST &ratings //list of results ) { LIST result; //tess output TBLOB *tessblob; //converted blob TEXTROW tessrow; //dummy row tess_bn_matching = FALSE; //turn it off tess_cn_matching = FALSE; //convert blob tessblob = make_tess_blob (blob, TRUE); //make dummy row make_tess_row(denorm, &tessrow); //classify result = AdaptiveClassifier (tessblob, NULL, &tessrow); free_blob(tessblob); //make our format convert_choice_list(result, ratings);}/********************************************************************** * tess_training_tester * * Matcher tester function which actually trains tess. **********************************************************************/void tess_training_tester( //call tess PBLOB *blob, //blob to match DENORM *denorm, //de-normaliser BOOL8 correct, //ly segmented char *text, //correct text inT32 count, //chars in text BLOB_CHOICE_LIST *ratings //list of results ) { TBLOB *tessblob; //converted blob TEXTROW tessrow; //dummy row if (correct) { NormMethod = character; //Force char norm spc 30/11/93 tess_bn_matching = FALSE; //turn it off tess_cn_matching = FALSE; //convert blob tessblob = make_tess_blob (blob, TRUE); //make dummy row make_tess_row(denorm, &tessrow); //learn it LearnBlob(tessblob, &tessrow, text); free_blob(tessblob); }}/********************************************************************** * tess_adapter * * Adapt to the word using the Tesseract mechanism. **********************************************************************/void tess_adapter( //adapt to word WERD *word, //bln word DENORM *denorm, //de-normalise const WERD_CHOICE& choice, //string for word const WERD_CHOICE& raw_choice, //before context const char *rejmap //reject map ) { TWERD *tessword; //converted word static TEXTROW tessrow; //dummy row //make dummy row make_tess_row(denorm, &tessrow); //make a word tessword = make_tess_word (word, &tessrow); AdaptToWord(tessword, &tessrow, choice, raw_choice, rejmap); //adapt to it delete_word(tessword); //free it}/********************************************************************** * tess_add_doc_word * * Add the given word to the document dictionary **********************************************************************/void tess_add_doc_word( //test acceptability WERD_CHOICE *word_choice //after context ) { A_CHOICE choice; //after context choice.rating = word_choice->rating (); choice.certainty = word_choice->certainty (); choice.string = (char *) word_choice->string ().string (); choice.lengths = (char *) word_choice->lengths ().string (); add_document_word(&choice);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?