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

Method TesseractExtractResult

deps/tesseract/api/baseapi.cpp:2690–2733  ·  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

2688 * and the bounding boxes of the characters.
2689 */
2690int TessBaseAPI::TesseractExtractResult(char** text,
2691 int** lengths,
2692 float** costs,
2693 int** x0,
2694 int** y0,
2695 int** x1,
2696 int** y1,
2697 PAGE_RES* page_res) {
2698 TESS_CHAR_LIST tess_chars;
2699 TESS_CHAR_IT tess_chars_it(&tess_chars);
2700 extract_result(&tess_chars_it, page_res);
2701 tess_chars_it.move_to_first();
2702 int n = tess_chars.length();
2703 int text_len = 0;
2704 *lengths = new int[n];
2705 *costs = new float[n];
2706 *x0 = new int[n];
2707 *y0 = new int[n];
2708 *x1 = new int[n];
2709 *y1 = new int[n];
2710 int i = 0;
2711 for (tess_chars_it.mark_cycle_pt();
2712 !tess_chars_it.cycled_list();
2713 tess_chars_it.forward(), i++) {
2714 TESS_CHAR *tc = tess_chars_it.data();
2715 text_len += (*lengths)[i] = tc->length;
2716 (*costs)[i] = tc->cost;
2717 (*x0)[i] = tc->box.left();
2718 (*y0)[i] = tc->box.bottom();
2719 (*x1)[i] = tc->box.right();
2720 (*y1)[i] = tc->box.top();
2721 }
2722 char *p = *text = new char[text_len];
2723
2724 tess_chars_it.move_to_first();
2725 for (tess_chars_it.mark_cycle_pt();
2726 !tess_chars_it.cycled_list();
2727 tess_chars_it.forward()) {
2728 TESS_CHAR *tc = tess_chars_it.data();
2729 strncpy(p, tc->unicode_repr, tc->length);
2730 p += tc->length;
2731 }
2732 return n;
2733}
2734
2735/** This method returns the features associated with the input blob. */
2736// The resulting features are returned in int_features, which must be

Callers

nothing calls this directly

Calls 7

extract_resultFunction · 0.85
dataMethod · 0.80
move_to_firstMethod · 0.45
lengthMethod · 0.45
mark_cycle_ptMethod · 0.45
cycled_listMethod · 0.45
forwardMethod · 0.45

Tested by

no test coverage detected