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]: ",