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]: ",
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
DLLSYM void tprintf(const char *format,...)
@ TEXTLINE_ORDER_LEFT_TO_RIGHT
@ TEXTLINE_ORDER_RIGHT_TO_LEFT
@ TEXTLINE_ORDER_TOP_TO_BOTTOM
@ 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
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)
TESS_LOCAL 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(int index) const
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
FCOORD re_rotation() const
PDBLK pdblk
Page Description Block.
FCOORD classify_rotation() const
bool right_to_left() const
Pix * render_mask(TBOX *mask_box)
const ParagraphModel * model
bool is_very_first_or_continuation
tesseract::ParagraphJustification justification() const
float base_line(float xpos) const
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
TBOX bounding_box() const
BlamerBundle * blamer_bundle
tesseract::BoxWord * box_word
WERD_CHOICE * best_choice
int cmp(const PAGE_RES_IT &other) const
WERD_RES * forward_block()
ROW_RES * prev_row() const
WERD_RES * restart_page_with_empties()
WERD_RES * forward_paragraph()
WERD_RES * forward_with_empties()
BLOCK_RES * prev_block() const
BLOCK_RES * block() const
POLY_BLOCK * poly_block() const
int16_t y() const
access_function
int16_t x() const
access function
void rotate(const FCOORD &vec)
static ICOORDELT * deep_copy(const ICOORDELT *src)
void rotate(const FCOORD vec)
void unrotate(const FCOORD &vec)
float angle() const
find angle
ICOORDELT_LIST * points()
PolyBlockType isA() const
void rotate(FCOORD rotation)
const STRING & unichar_string() const
void rotate(const FCOORD &vec)
TBOX bounding_union(const TBOX &box) const
C_BLOB_LIST * cblob_list()
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
TBOX bounding_box() const
const char * string() const