22 #include "allheaders.h"
32 int scaled_yres,
int rect_left,
int rect_top,
33 int rect_width,
int rect_height)
34 : page_res_(page_res),
40 include_upper_dots_(false),
41 include_lower_dots_(false),
43 scaled_yres_(scaled_yres),
44 rect_left_(rect_left),
46 rect_width_(rect_width),
47 rect_height_(rect_height) {
63 : page_res_(src.page_res_),
64 tesseract_(src.tesseract_),
66 word_length_(src.word_length_),
67 blob_index_(src.blob_index_),
69 include_upper_dots_(src.include_upper_dots_),
70 include_lower_dots_(src.include_lower_dots_),
72 scaled_yres_(src.scaled_yres_),
73 rect_left_(src.rect_left_),
74 rect_top_(src.rect_top_),
75 rect_width_(src.rect_width_),
76 rect_height_(src.rect_height_) {
99 return (
it_ ==
nullptr &&
it_ == other) ||
100 ((other !=
nullptr) && (
it_ !=
nullptr) && (*
it_ == *other));
112 if (
it_->
block() ==
nullptr)
return;
116 while (next_para.
cmp(*
it_) <= 0) {
149 if (
it_->
block() ==
nullptr)
return false;
187 if (
it_->
block() ==
nullptr)
return false;
188 if (
it_->
word() ==
nullptr)
return true;
212 if (
Empty(element))
return true;
221 if (next.
Empty(element))
return true;
222 while (element > level) {
268 int* right,
int* bottom)
const {
272 PARA *para =
nullptr;
328 int* right,
int* bottom)
const {
329 return BoundingBox(level, 0, left, top, right, bottom);
334 int* right,
int* bottom)
const {
351 if (
it_->
block() ==
nullptr)
return true;
376 ICOORDELT_LIST vertices;
380 ICOORDELT_IT it(poly.
points());
381 Pta* pta = ptaCreate(it.length());
383 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward(), ++num_pts) {
418 int left, top, right, bottom;
424 Box* box = boxCreate(left, top, right - left, bottom - top);
431 int mask_x = left - mask_box.
left();
434 pixRasterop(pix, std::max(0, -mask_x), std::max(0, -mask_y), pixGetWidth(pix),
435 pixGetHeight(pix), PIX_SRC & PIX_DST, mask, std::max(0, mask_x),
436 std::max(0, mask_y));
455 int* left,
int* top)
const {
457 if (!
BoundingBox(level, left, top, &right, &bottom))
459 if (original_img ==
nullptr)
463 *left = std::max(*left - padding, 0);
464 *top = std::max(*top - padding, 0);
467 Box* box = boxCreate(*left, *top, right - *left, bottom - *top);
468 Pix* grey_pix = pixClipRectangle(original_img, box,
nullptr);
475 int mask_x = *left - mask_box.
left();
476 int mask_y = *top - (pixGetHeight(original_img) - mask_box.
top());
477 int width = pixGetWidth(grey_pix);
478 int height = pixGetHeight(grey_pix);
479 Pix* resized_mask = pixCreate(width, height, 1);
480 pixRasterop(resized_mask, std::max(0, -mask_x), std::max(0, -mask_y), width, height,
481 PIX_SRC, mask, std::max(0, mask_x), std::max(0, mask_y));
483 pixDilateBrick(resized_mask, resized_mask, 2 * padding + 1,
485 pixInvert(resized_mask, resized_mask);
486 pixSetMasked(grey_pix, resized_mask, UINT32_MAX);
487 pixDestroy(&resized_mask);
498 int* x1,
int* y1,
int* x2,
int* y2)
const {
499 if (
it_->
word() ==
nullptr)
return false;
505 int left = box.
left();
506 ICOORD startpt(left,
static_cast<int16_t
>(row->
base_line(left) + 0.5));
507 int right = box.
right();
508 ICOORD endpt(right,
static_cast<int16_t
>(row->
base_line(right) + 0.5));
522 float *deskew_angle)
const {
526 FCOORD up_in_image(0.0, 1.0);
530 if (up_in_image.
x() == 0.0F) {
531 if (up_in_image.
y() > 0.0F) {
536 }
else if (up_in_image.
x() > 0.0F) {
553 const bool is_mongolian =
false;
554 *textline_order = is_vertical_text
562 *deskew_angle = -skew.
angle();
568 int *first_line_indent)
const {
588 if (word_res ==
nullptr) {
599 if (word_res->
box_word !=
nullptr) {
601 tprintf(
"Corrupted word! best_choice[len=%d] = %s, box_word[len=%d]: ",