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

Function extract_result

deps/tesseract/api/baseapi.cpp:2660–2684  ·  view source on GitHub ↗

* Extract the OCR results, costs (penalty points for uncertainty), * and the bounding boxes of the characters. */

Source from the content-addressed store, hash-verified

2658 * and the bounding boxes of the characters.
2659 */
2660static void extract_result(TESS_CHAR_IT* out,
2661 PAGE_RES* page_res) {
2662 PAGE_RES_IT page_res_it(page_res);
2663 int word_count = 0;
2664 while (page_res_it.word() != NULL) {
2665 WERD_RES *word = page_res_it.word();
2666 const char *str = word->best_choice->unichar_string().string();
2667 const char *len = word->best_choice->unichar_lengths().string();
2668 TBOX real_rect = word->word->bounding_box();
2669
2670 if (word_count)
2671 add_space(out);
2672 int n = strlen(len);
2673 for (int i = 0; i < n; i++) {
2674 TESS_CHAR *tc = new TESS_CHAR(rating_to_cost(word->best_choice->rating()),
2675 str, *len);
2676 tc->box = real_rect.intersection(word->box_word->BlobBox(i));
2677 out->add_after_then_move(tc);
2678 str += *len;
2679 len++;
2680 }
2681 page_res_it.forward();
2682 word_count++;
2683 }
2684}
2685
2686/**
2687 * Extract the OCR results, costs (penalty points for uncertainty),

Callers 1

Calls 9

add_spaceFunction · 0.85
rating_to_costFunction · 0.85
ratingMethod · 0.80
wordMethod · 0.45
stringMethod · 0.45
bounding_boxMethod · 0.45
intersectionMethod · 0.45
add_after_then_moveMethod · 0.45
forwardMethod · 0.45

Tested by

no test coverage detected