22 #include "allheaders.h"
30 int scale,
int scaled_yres,
31 int rect_left,
int rect_top,
32 int rect_width,
int rect_height)
33 : page_res_(page_res), tesseract_(tesseract),
34 word_(
NULL), word_length_(0), blob_index_(0), cblob_it_(
NULL),
35 scale_(scale), scaled_yres_(scaled_yres),
36 rect_left_(rect_left), rect_top_(rect_top),
37 rect_width_(rect_width), rect_height_(rect_height) {
53 : page_res_(src.page_res_), tesseract_(src.tesseract_),
54 word_(
NULL), word_length_(src.word_length_),
55 blob_index_(src.blob_index_), cblob_it_(
NULL),
56 scale_(src.scale_), scaled_yres_(src.scaled_yres_),
57 rect_left_(src.rect_left_), rect_top_(src.rect_top_),
58 rect_width_(src.rect_width_), rect_height_(src.rect_height_) {
96 while (next_para.
cmp(*
it_) <= 0) {
192 if (
Empty(element))
return true;
201 if (next.
Empty(element))
return true;
202 while (element > level) {
248 int* right,
int* bottom)
const {
305 int* right,
int* bottom)
const {
361 int left, top, right, bottom;
368 int bleft, btop, bright, bbottom;
372 pixRasterop(pix, 0, 0, pixGetWidth(pix), pixGetHeight(pix),
378 Box* box = boxCreate(left - bleft, top - btop,
379 right - left, bottom - top);
380 Pix* pix2 = pixClipRectangle(pix, box,
NULL);
393 Box* box = boxCreate(left, top, right - left, bottom - top);
412 int* left,
int* top)
const {
414 if (!
BoundingBox(level, left, top, &right, &bottom))
421 *left =
MAX(*left - padding, 0);
422 *top =
MAX(*top - padding, 0);
425 Box* box = boxCreate(*left, *top, right - *left, bottom - *top);
426 Pix* grey_pix = pixClipRectangle(pix, box,
NULL);
430 Pix* expanded_mask = pixCreate(right - *left, bottom - *top, 1);
431 pixRasterop(expanded_mask, padding, padding,
432 pixGetWidth(mask), pixGetHeight(mask),
433 PIX_SRC, mask, 0, 0);
435 pixDilateBrick(expanded_mask, expanded_mask, 2*padding + 1, 2*padding + 1);
436 pixInvert(expanded_mask, expanded_mask);
437 pixSetMasked(grey_pix, expanded_mask, 255);
438 pixDestroy(&expanded_mask);
449 int* x1,
int* y1,
int* x2,
int* y2)
const {
456 int left = box.
left();
458 int right = box.
right();
473 float *deskew_angle)
const {
477 FCOORD up_in_image(0.0, 1.0);
481 if (up_in_image.
x() == 0.0F) {
482 if (up_in_image.
y() > 0.0F) {
487 }
else if (up_in_image.
x() > 0.0F) {
504 bool is_mongolian =
false;
505 *textline_order = is_vertical_text
513 *deskew_angle = -skew.
angle();
519 int *first_line_indent)
const {
538 if (word_res ==
NULL) {
551 tprintf(
"Corrupted word! best_choice[len=%d] = %s, box_word[len=%d]: ",
TBOX bounding_union(const TBOX &box) const
BLOCK_RES * prev_block() const
int Cmp(const PageIterator &other) const
const STRING & unichar_string() const
C_BLOB_LIST * cblob_list()
bool BoundingBoxInternal(PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const
void rotate(const FCOORD &vec)
WERD_RES * forward_block()
virtual void RestartRow()
const ParagraphModel * model
bool BoundingBox(PageIteratorLevel level, int *left, int *top, int *right, int *bottom) const
virtual bool Next(PageIteratorLevel level)
Pix * GetImage(PageIteratorLevel level, int padding, int *left, int *top) const
WERD_RES * forward_paragraph()
PolyBlockType isA() const
BLOCK_RES * block() const
bool PositionedAtSameWord(const PAGE_RES_IT *other) const
float base_line(float xpos) const
POLY_BLOCK * poly_block() const
const char * string() const
const TBOX & bounding_box() const
WERD_RES * forward_with_empties()
bool IsWithinFirstTextlineOfParagraph() const
TESS_LOCAL void BeginWord(int offset)
void unrotate(const FCOORD &vec)
DLLSYM void tprintf(const char *format,...)
void Orientation(tesseract::Orientation *orientation, tesseract::WritingDirection *writing_direction, tesseract::TextlineOrder *textline_order, float *deskew_angle) const
const PageIterator & operator=(const PageIterator &src)
void rotate(const FCOORD vec)
bool right_to_left() const
FCOORD classify_rotation() const
float angle() const
find angle
virtual void RestartParagraph()
void ParagraphInfo(tesseract::ParagraphJustification *justification, bool *is_list_item, bool *is_crown, int *first_line_indent) const
ROW_RES * prev_row() const
bool Empty(PageIteratorLevel level) const
TBOX bounding_box() const
tesseract::BoxWord * box_word
const TBOX & BlobBox(int index) const
void rotate(const FCOORD &vec)
virtual bool IsAtFinalElement(PageIteratorLevel level, PageIteratorLevel element) const
PolyBlockType BlockType() const
bool is_very_first_or_continuation
bool Baseline(PageIteratorLevel level, int *x1, int *y1, int *x2, int *y2) const
Pix * GetBinaryImage(PageIteratorLevel level) const
int cmp(const PAGE_RES_IT &other) const
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
FCOORD re_rotation() const
virtual bool IsAtBeginningOf(PageIteratorLevel level) const
WERD_RES * restart_page_with_empties()
PageIterator(PAGE_RES *page_res, Tesseract *tesseract, int scale, int scaled_yres, int rect_left, int rect_top, int rect_width, int rect_height)
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
WERD_CHOICE * best_choice