Extract the OCR results, costs (penalty points for uncertainty), and the bounding boxes of the characters.
2521 TESS_CHAR_LIST tess_chars;
2522 TESS_CHAR_IT tess_chars_it(&tess_chars);
2523 extract_result(&tess_chars_it, page_res);
2524 tess_chars_it.move_to_first();
2525 int n = tess_chars.length();
2527 *lengths =
new int[n];
2528 *costs =
new float[n];
2534 for (tess_chars_it.mark_cycle_pt();
2535 !tess_chars_it.cycled_list();
2536 tess_chars_it.forward(), i++) {
2537 TESS_CHAR *tc = tess_chars_it.data();
2538 text_len += (*lengths)[i] = tc->length;
2539 (*costs)[i] = tc->cost;
2540 (*x0)[i] = tc->box.left();
2541 (*y0)[i] = tc->box.bottom();
2542 (*x1)[i] = tc->box.right();
2543 (*y1)[i] = tc->box.top();
2545 char *p = *text =
new char[text_len];
2547 tess_chars_it.move_to_first();
2548 for (tess_chars_it.mark_cycle_pt();
2549 !tess_chars_it.cycled_list();
2550 tess_chars_it.forward()) {
2551 TESS_CHAR *tc = tess_chars_it.data();
2552 strncpy(p, tc->unicode_repr, tc->length);