21 #include "allheaders.h"
31 int scaled_yres,
int rect_left,
int rect_top,
32 int rect_width,
int rect_height)
33 : page_res_(page_res),
39 include_upper_dots_(false),
40 include_lower_dots_(false),
42 scaled_yres_(scaled_yres),
43 rect_left_(rect_left),
45 rect_width_(rect_width),
46 rect_height_(rect_height) {
62 : page_res_(src.page_res_),
63 tesseract_(src.tesseract_),
65 word_length_(src.word_length_),
66 blob_index_(src.blob_index_),
68 include_upper_dots_(src.include_upper_dots_),
69 include_lower_dots_(src.include_lower_dots_),
71 scaled_yres_(src.scaled_yres_),
72 rect_left_(src.rect_left_),
73 rect_top_(src.rect_top_),
74 rect_width_(src.rect_width_),
75 rect_height_(src.rect_height_) {
98 return (
it_ ==
nullptr &&
it_ == other) ||
99 ((other !=
nullptr) && (
it_ !=
nullptr) && (*
it_ == *other));
111 if (
it_->
block() ==
nullptr)
return;
115 while (next_para.
cmp(*
it_) <= 0) {
148 if (
it_->
block() ==
nullptr)
return false;
186 if (
it_->
block() ==
nullptr)
return false;
187 if (
it_->
word() ==
nullptr)
return true;
211 if (
Empty(element))
return true;
220 if (next.
Empty(element))
return true;
221 while (element > level) {
222 element = static_cast<PageIteratorLevel>(element - 1);
267 int* right,
int* bottom)
const {
271 PARA *para =
nullptr;
327 int* right,
int* bottom)
const {
328 return BoundingBox(level, 0, left, top, right, bottom);
333 int* right,
int* bottom)
const {
350 if (
it_->
block() ==
nullptr)
return true;
375 ICOORDELT_LIST vertices;
379 ICOORDELT_IT it(poly.points());
380 Pta* pta = ptaCreate(it.length());
382 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward(), ++num_pts) {
417 int left, top, right, bottom;
423 Box* box = boxCreate(left, top, right - left, bottom - top);
430 int mask_x = left - mask_box.
left();
433 pixRasterop(pix, std::max(0, -mask_x), std::max(0, -mask_y), pixGetWidth(pix),
434 pixGetHeight(pix), PIX_SRC & PIX_DST, mask, std::max(0, mask_x),
435 std::max(0, mask_y));
454 int* left,
int* top)
const {
456 if (!
BoundingBox(level, left, top, &right, &bottom))
458 if (original_img ==
nullptr)
462 *left = std::max(*left - padding, 0);
463 *top = std::max(*top - padding, 0);
466 Box* box = boxCreate(*left, *top, right - *left, bottom - *top);
467 Pix* grey_pix = pixClipRectangle(original_img, box,
nullptr);
474 int mask_x = *left - mask_box.
left();
475 int mask_y = *top - (pixGetHeight(original_img) - mask_box.
top());
476 int width = pixGetWidth(grey_pix);
477 int height = pixGetHeight(grey_pix);
478 Pix* resized_mask = pixCreate(width, height, 1);
479 pixRasterop(resized_mask, std::max(0, -mask_x), std::max(0, -mask_y), width, height,
480 PIX_SRC, mask, std::max(0, mask_x), std::max(0, mask_y));
482 pixDilateBrick(resized_mask, resized_mask, 2 * padding + 1,
484 pixInvert(resized_mask, resized_mask);
485 pixSetMasked(grey_pix, resized_mask, UINT32_MAX);
486 pixDestroy(&resized_mask);
497 int* x1,
int* y1,
int* x2,
int* y2)
const {
498 if (
it_->
word() ==
nullptr)
return false;
504 int left = box.
left();
505 ICOORD startpt(left, static_cast<int16_t>(row->
base_line(left) + 0.5));
506 int right = box.
right();
507 ICOORD endpt(right, static_cast<int16_t>(row->
base_line(right) + 0.5));
521 float *deskew_angle)
const {
525 FCOORD up_in_image(0.0, 1.0);
529 if (up_in_image.
x() == 0.0F) {
530 if (up_in_image.
y() > 0.0F) {
535 }
else if (up_in_image.
x() > 0.0F) {
552 const bool is_mongolian =
false;
553 *textline_order = is_vertical_text
561 *deskew_angle = -skew.
angle();
567 int *first_line_indent)
const {
587 if (word_res ==
nullptr) {
598 if (word_res->
box_word !=
nullptr) {
600 tprintf(
"Corrupted word! best_choice[len=%d] = %s, box_word[len=%d]: ",