* Extract the OCR results, costs (penalty points for uncertainty), * and the bounding boxes of the characters. */
| 2658 | * and the bounding boxes of the characters. |
| 2659 | */ |
| 2660 | static 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), |
no test coverage detected