20#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));
117 while (next_para.
cmp(*
it_) <= 0) {
224 if (
Empty(element)) {
235 if (
next.Empty(element)) {
238 while (element > level) {
240 if (!
next.IsAtBeginningOf(element)) {
287 int *top,
int *right,
293 PARA *para =
nullptr;
350 int *right,
int *bottom)
const {
351 return BoundingBox(level, 0, left, top, right, bottom);
355 int *left,
int *top,
int *right,
409 ICOORDELT_LIST vertices;
413 ICOORDELT_IT it(poly.
points());
414 Pta *pta = ptaCreate(it.length());
416 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward(), ++num_pts) {
451 int left, top, right, bottom;
459 Box *box = boxCreate(left, top, right - left, bottom - top);
466 int mask_x = left - mask_box.
left();
469 pixRasterop(pix, std::max(0, -mask_x), std::max(0, -mask_y),
470 pixGetWidth(pix), pixGetHeight(pix), PIX_SRC & PIX_DST, mask,
471 std::max(0, mask_x), std::max(0, mask_y));
489 Pix *original_img,
int *left,
int *top)
const {
491 if (!
BoundingBox(level, left, top, &right, &bottom)) {
494 if (original_img ==
nullptr) {
499 *left = std::max(*left - padding, 0);
500 *top = std::max(*top - padding, 0);
503 Box *box = boxCreate(*left, *top, right - *left, bottom - *top);
504 Image grey_pix = pixClipRectangle(original_img, box,
nullptr);
511 int mask_x = *left - mask_box.
left();
512 int mask_y = *top - (pixGetHeight(original_img) - mask_box.
top());
513 int width = pixGetWidth(grey_pix);
514 int height = pixGetHeight(grey_pix);
515 Image resized_mask = pixCreate(width, height, 1);
516 pixRasterop(resized_mask, std::max(0, -mask_x), std::max(0, -mask_y), width,
517 height, PIX_SRC, mask, std::max(0, mask_x),
518 std::max(0, mask_y));
520 pixDilateBrick(resized_mask, resized_mask, 2 * padding + 1,
522 pixInvert(resized_mask, resized_mask);
523 pixSetMasked(grey_pix, resized_mask, UINT32_MAX);
543 int left = box.
left();
544 ICOORD startpt(left,
static_cast<int16_t
>(row->
base_line(left) + 0.5));
545 int right = box.
right();
546 ICOORD endpt(right,
static_cast<int16_t
>(row->
base_line(right) + 0.5));
558 float *ascenders)
const {
568 float *deskew_angle)
const {
570 if (block_res ==
nullptr) {
577 auto *block = block_res->block;
580 FCOORD up_in_image(0.0, 1.0);
581 up_in_image.
unrotate(block->classify_rotation());
582 up_in_image.
rotate(block->re_rotation());
584 if (up_in_image.
x() == 0.0F) {
585 if (up_in_image.
y() > 0.0F) {
590 }
else if (up_in_image.
x() > 0.0F) {
597 bool is_vertical_text = (block->classify_rotation().x() == 0.0);
598 bool right_to_left = block->right_to_left();
599 *writing_direction = is_vertical_text
605 const bool is_mongolian =
false;
606 *textline_order = is_vertical_text
612 FCOORD skew = block->skew();
613 *deskew_angle = -skew.
angle();
617 bool *is_list_item,
bool *is_crown,
618 int *first_line_indent)
const {
638 if (word_res ==
nullptr) {
649 if (word_res->
box_word !=
nullptr) {
651 tprintf(
"Corrupted word! best_choice[len=%d] = %s, box_word[len=%d]: ",
@ TEXTLINE_ORDER_LEFT_TO_RIGHT
@ TEXTLINE_ORDER_RIGHT_TO_LEFT
@ TEXTLINE_ORDER_TOP_TO_BOTTOM
void tprintf(const char *format,...)
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
@ WRITING_DIRECTION_TOP_TO_BOTTOM
@ WRITING_DIRECTION_LEFT_TO_RIGHT
@ WRITING_DIRECTION_RIGHT_TO_LEFT
void ParagraphInfo(tesseract::ParagraphJustification *justification, bool *is_list_item, bool *is_crown, int *first_line_indent) const
int Cmp(const PageIterator &other) const
bool BoundingBoxInternal(PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const
virtual void RestartRow()
virtual bool Next(PageIteratorLevel level)
Pta * BlockPolygon() const
PolyBlockType BlockType() const
virtual bool IsAtBeginningOf(PageIteratorLevel level) const
bool PositionedAtSameWord(const PAGE_RES_IT *other) const
void RowAttributes(float *row_height, float *descenders, float *ascenders) const
bool SetWordBlamerBundle(BlamerBundle *blamer_bundle)
Pix * GetImage(PageIteratorLevel level, int padding, Pix *original_img, int *left, int *top) const
bool IsWithinFirstTextlineOfParagraph() const
virtual void RestartParagraph()
bool Empty(PageIteratorLevel level) const
bool Baseline(PageIteratorLevel level, int *x1, int *y1, int *x2, int *y2) const
const PageIterator & operator=(const PageIterator &src)
void BeginWord(int offset)
Pix * GetBinaryImage(PageIteratorLevel level) const
bool BoundingBox(PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const
virtual bool IsAtFinalElement(PageIteratorLevel level, PageIteratorLevel element) const
PageIterator(PAGE_RES *page_res, Tesseract *tesseract, int scale, int scaled_yres, int rect_left, int rect_top, int rect_width, int rect_height)
void Orientation(tesseract::Orientation *orientation, tesseract::WritingDirection *writing_direction, tesseract::TextlineOrder *textline_order, float *deskew_angle) const
const TBOX & bounding_box() const
const TBOX & BlobBox(unsigned index) const
FCOORD re_rotation() const
PDBLK pdblk
Page Description Block.
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
Image render_mask(TBOX *mask_box)
const ParagraphModel * model
bool is_very_first_or_continuation
tesseract::ParagraphJustification justification() const
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
float base_line(float xpos) const
TBOX bounding_box() const
WERD_CHOICE * best_choice
BlamerBundle * blamer_bundle
tesseract::BoxWord * box_word
BLOCK_RES * block() const
BLOCK_RES * prev_block() const
WERD_RES * forward_paragraph()
WERD_RES * forward_with_empties()
WERD_RES * forward_block()
WERD_RES * restart_page_with_empties()
ROW_RES * prev_row() const
int cmp(const PAGE_RES_IT &other) const
POLY_BLOCK * poly_block() const
void rotate(const FCOORD &vec)
TDimension y() const
access_function
TDimension x() const
access function
static ICOORDELT * deep_copy(const ICOORDELT *src)
float angle() const
find angle
void unrotate(const FCOORD &vec)
void rotate(const FCOORD vec)
ICOORDELT_LIST * points()
PolyBlockType isA() const
void rotate(FCOORD rotation)
std::string & unichar_string()
void rotate(const FCOORD &vec)
TBOX bounding_union(const TBOX &box) const
TDimension bottom() const
TBOX bounding_box() const
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
C_BLOB_LIST * cblob_list()