MCPcopy Create free account
hub / github.com/creatale/node-dv / Recognize

Method Recognize

deps/tesseract/api/baseapi.cpp:829–903  ·  view source on GitHub ↗

* Recognize the tesseract global image and return the result as Tesseract * internal structures. */

Source from the content-addressed store, hash-verified

827 * internal structures.
828 */
829int TessBaseAPI::Recognize(ETEXT_DESC* monitor) {
830 if (tesseract_ == NULL)
831 return -1;
832 if (FindLines() != 0)
833 return -1;
834 delete page_res_;
835 if (block_list_->empty()) {
836 page_res_ = new PAGE_RES(false, block_list_,
837 &tesseract_->prev_word_best_choice_);
838 return 0; // Empty page.
839 }
840
841 tesseract_->SetBlackAndWhitelist();
842 recognition_done_ = true;
843 if (tesseract_->tessedit_resegment_from_line_boxes) {
844 page_res_ = tesseract_->ApplyBoxes(*input_file_, true, block_list_);
845 } else if (tesseract_->tessedit_resegment_from_boxes) {
846 page_res_ = tesseract_->ApplyBoxes(*input_file_, false, block_list_);
847 } else {
848 // TODO(rays) LSTM here.
849 page_res_ = new PAGE_RES(false,
850 block_list_, &tesseract_->prev_word_best_choice_);
851 }
852 if (page_res_ == NULL) {
853 return -1;
854 }
855 if (tesseract_->tessedit_make_boxes_from_boxes) {
856 tesseract_->CorrectClassifyWords(page_res_);
857 return 0;
858 }
859
860 if (truth_cb_ != NULL) {
861 tesseract_->wordrec_run_blamer.set_value(true);
862 PageIterator *page_it = new PageIterator(
863 page_res_, tesseract_, thresholder_->GetScaleFactor(),
864 thresholder_->GetScaledYResolution(),
865 rect_left_, rect_top_, rect_width_, rect_height_);
866 truth_cb_->Run(tesseract_->getDict().getUnicharset(),
867 image_height_, page_it, this->tesseract()->pix_grey());
868 delete page_it;
869 }
870
871 int result = 0;
872 if (tesseract_->interactive_display_mode) {
873 #ifndef GRAPHICS_DISABLED
874 tesseract_->pgeditor_main(rect_width_, rect_height_, page_res_);
875 #endif // GRAPHICS_DISABLED
876 // The page_res is invalid after an interactive session, so cleanup
877 // in a way that lets us continue to the next page without crashing.
878 delete page_res_;
879 page_res_ = NULL;
880 return -1;
881 } else if (tesseract_->tessedit_train_from_boxes) {
882 STRING fontname;
883 ExtractFontName(*output_file_, &fontname);
884 tesseract_->ApplyBoxTraining(fontname, page_res_);
885 } else if (tesseract_->tessedit_ambigs_training) {
886 FILE *training_output_file = tesseract_->init_recog_training(*input_file_);

Callers 2

TransformResultMethod · 0.45
TessBaseAPIRecognizeFunction · 0.45

Calls 13

ExtractFontNameFunction · 0.85
DetectParagraphsFunction · 0.85
SetBlackAndWhitelistMethod · 0.80
ApplyBoxesMethod · 0.80
CorrectClassifyWordsMethod · 0.80
pgeditor_mainMethod · 0.80
ApplyBoxTrainingMethod · 0.80
init_recog_trainingMethod · 0.80
recog_all_wordsMethod · 0.80
emptyMethod · 0.45
set_valueMethod · 0.45

Tested by

no test coverage detected