tesseract v5.3.3.20231005
tesseract::TO_ROW Class Reference

#include <blobbox.h>

Inheritance diagram for tesseract::TO_ROW:
tesseract::ELIST2_LINK

Public Member Functions

 TO_ROW ()
 
 TO_ROW (BLOBNBOX *blob, float top, float bottom, float row_size)
 
void print () const
 
float max_y () const
 
float min_y () const
 
float mean_y () const
 
float initial_min_y () const
 
float line_m () const
 
float line_c () const
 
float line_error () const
 
float parallel_c () const
 
float parallel_error () const
 
float believability () const
 
float intercept () const
 
void add_blob (BLOBNBOX *blob, float top, float bottom, float row_size)
 
void insert_blob (BLOBNBOX *blob)
 
BLOBNBOX_LIST * blob_list ()
 
void set_line (float new_m, float new_c, float new_error)
 
void set_parallel_line (float gradient, float new_c, float new_error)
 
void set_limits (float new_min, float new_max)
 
void compute_vertical_projection ()
 
bool rep_chars_marked () const
 
void clear_rep_chars_marked ()
 
int num_repeated_sets () const
 
void set_num_repeated_sets (int num_sets)
 
- Public Member Functions inherited from tesseract::ELIST2_LINK
 ELIST2_LINK ()
 
 ELIST2_LINK (const ELIST2_LINK &)=delete
 
void operator= (const ELIST2_LINK &)
 

Public Attributes

bool merged = false
 
bool all_caps
 
bool used_dm_model
 
int16_t projection_left
 
int16_t projection_right
 
PITCH_TYPE pitch_decision
 
float fixed_pitch
 
float fp_space
 
float fp_nonsp
 
float pr_space
 
float pr_nonsp
 
float spacing
 
float xheight
 
int xheight_evidence
 
float ascrise
 
float descdrop
 
float body_size
 
int32_t min_space
 
int32_t max_nonspace
 
int32_t space_threshold
 
float kern_size
 
float space_size
 
WERD_LIST rep_words
 
ICOORDELT_LIST char_cells
 
QSPLINE baseline
 
STATS projection
 

Static Public Attributes

static const int kErrorWeight = 3
 

Detailed Description

Definition at line 555 of file blobbox.h.

Constructor & Destructor Documentation

◆ TO_ROW() [1/2]

tesseract::TO_ROW::TO_ROW ( )
inline

Definition at line 559 of file blobbox.h.

559 {
560 clear();
561 } // empty

◆ TO_ROW() [2/2]

tesseract::TO_ROW::TO_ROW ( BLOBNBOX blob,
float  top,
float  bottom,
float  row_size 
)

Definition at line 690 of file blobbox.cpp.

695 {
696 clear();
697 y_min = bottom;
698 y_max = top;
699 initial_y_min = bottom;
700
701 float diff; // in size
702 BLOBNBOX_IT it = &blobs; // list of blobs
703
704 it.add_to_end(blob);
705 diff = top - bottom - row_size;
706 if (diff > 0) {
707 y_max -= diff / 2;
708 y_min += diff / 2;
709 }
710 // very small object
711 else if ((top - bottom) * 3 < row_size) {
712 diff = row_size / 3 + bottom - top;
713 y_max += diff / 2;
714 y_min -= diff / 2;
715 }
716}

Member Function Documentation

◆ add_blob()

void tesseract::TO_ROW::add_blob ( BLOBNBOX blob,
float  top,
float  bottom,
float  row_size 
)

Definition at line 734 of file blobbox.cpp.

739 {
740 float allowed; // allowed expansion
741 float available; // expansion
742 BLOBNBOX_IT it = &blobs; // list of blobs
743
744 it.add_to_end(blob);
745 allowed = row_size + y_min - y_max;
746 if (allowed > 0) {
747 available = top > y_max ? top - y_max : 0;
748 if (bottom < y_min) {
749 // total available
750 available += y_min - bottom;
751 }
752 if (available > 0) {
753 available += available; // do it gradually
754 if (available < allowed) {
755 available = allowed;
756 }
757 if (bottom < y_min) {
758 y_min -= (y_min - bottom) * allowed / available;
759 }
760 if (top > y_max) {
761 y_max += (top - y_max) * allowed / available;
762 }
763 }
764 }
765}

◆ believability()

float tesseract::TO_ROW::believability ( ) const
inline

Definition at line 595 of file blobbox.h.

595 { // baseline goodness
596 return credibility;
597 }

◆ blob_list()

BLOBNBOX_LIST * tesseract::TO_ROW::blob_list ( )
inline

Definition at line 608 of file blobbox.h.

608 { // get list
609 return &blobs;
610 }

◆ clear_rep_chars_marked()

void tesseract::TO_ROW::clear_rep_chars_marked ( )
inline

Definition at line 640 of file blobbox.h.

640 {
641 num_repeated_sets_ = -1;
642 }

◆ compute_vertical_projection()

void tesseract::TO_ROW::compute_vertical_projection ( )

Definition at line 799 of file blobbox.cpp.

799 { // project whole row
800 TBOX row_box; // bound of row
801 BLOBNBOX *blob; // current blob
802 TBOX blob_box; // bounding box
803 BLOBNBOX_IT blob_it = blob_list();
804
805 if (blob_it.empty()) {
806 return;
807 }
808 row_box = blob_it.data()->bounding_box();
809 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
810 row_box += blob_it.data()->bounding_box();
811 }
812
813 projection.set_range(row_box.left() - PROJECTION_MARGIN, row_box.right() + PROJECTION_MARGIN - 1);
814 projection_left = row_box.left() - PROJECTION_MARGIN;
815 projection_right = row_box.right() + PROJECTION_MARGIN;
816 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
817 blob = blob_it.data();
818 if (blob->cblob() != nullptr) {
819 vertical_cblob_projection(blob->cblob(), &projection);
820 }
821 }
822}
#define PROJECTION_MARGIN
Definition: blobbox.cpp:39
@ TBOX
void vertical_cblob_projection(C_BLOB *blob, STATS *stats)
Definition: blobbox.cpp:871
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:608
STATS projection
Definition: blobbox.h:677
int16_t projection_left
Definition: blobbox.h:654
int16_t projection_right
Definition: blobbox.h:655
bool set_range(int32_t min_bucket_value, int32_t max_bucket_value)
Definition: statistc.cpp:59

◆ initial_min_y()

float tesseract::TO_ROW::initial_min_y ( ) const
inline

Definition at line 577 of file blobbox.h.

577 {
578 return initial_y_min;
579 }

◆ insert_blob()

void tesseract::TO_ROW::insert_blob ( BLOBNBOX blob)

Definition at line 773 of file blobbox.cpp.

775 {
776 BLOBNBOX_IT it = &blobs; // list of blobs
777
778 if (it.empty()) {
779 it.add_before_then_move(blob);
780 } else {
781 it.mark_cycle_pt();
782 while (!it.cycled_list() && it.data()->bounding_box().left() <= blob->bounding_box().left()) {
783 it.forward();
784 }
785 if (it.cycled_list()) {
786 it.add_to_end(blob);
787 } else {
788 it.add_before_stay_put(blob);
789 }
790 }
791}

◆ intercept()

float tesseract::TO_ROW::intercept ( ) const
inline

Definition at line 598 of file blobbox.h.

598 { // real parallel_c
599 return y_origin;
600 }

◆ line_c()

float tesseract::TO_ROW::line_c ( ) const
inline

Definition at line 583 of file blobbox.h.

583 {
584 return c;
585 }

◆ line_error()

float tesseract::TO_ROW::line_error ( ) const
inline

Definition at line 586 of file blobbox.h.

586 {
587 return error;
588 }

◆ line_m()

float tesseract::TO_ROW::line_m ( ) const
inline

Definition at line 580 of file blobbox.h.

580 { // access to line fit
581 return m;
582 }

◆ max_y()

float tesseract::TO_ROW::max_y ( ) const
inline

Definition at line 568 of file blobbox.h.

568 { // access function
569 return y_max;
570 }

◆ mean_y()

float tesseract::TO_ROW::mean_y ( ) const
inline

Definition at line 574 of file blobbox.h.

574 {
575 return (y_min + y_max) / 2.0f;
576 }

◆ min_y()

float tesseract::TO_ROW::min_y ( ) const
inline

Definition at line 571 of file blobbox.h.

571 {
572 return y_min;
573 }

◆ num_repeated_sets()

int tesseract::TO_ROW::num_repeated_sets ( ) const
inline

Definition at line 643 of file blobbox.h.

643 {
644 return num_repeated_sets_;
645 }

◆ parallel_c()

float tesseract::TO_ROW::parallel_c ( ) const
inline

Definition at line 589 of file blobbox.h.

589 {
590 return para_c;
591 }

◆ parallel_error()

float tesseract::TO_ROW::parallel_error ( ) const
inline

Definition at line 592 of file blobbox.h.

592 {
593 return para_error;
594 }

◆ print()

void tesseract::TO_ROW::print ( ) const

Definition at line 718 of file blobbox.cpp.

718 {
719 tprintf(
720 "pitch=%d, fp=%g, fps=%g, fpns=%g, prs=%g, prns=%g,"
721 " spacing=%g xh=%g y_origin=%g xev=%d, asc=%g, desc=%g,"
722 " body=%g, minsp=%d maxnsp=%d, thr=%d kern=%g sp=%g\n",
726}
void tprintf(const char *format,...)
Definition: tprintf.cpp:41
int xheight_evidence
Definition: blobbox.h:664
int32_t min_space
Definition: blobbox.h:669
int32_t max_nonspace
Definition: blobbox.h:670
float space_size
Definition: blobbox.h:673
float fixed_pitch
Definition: blobbox.h:657
int32_t space_threshold
Definition: blobbox.h:671
PITCH_TYPE pitch_decision
Definition: blobbox.h:656

◆ rep_chars_marked()

bool tesseract::TO_ROW::rep_chars_marked ( ) const
inline

Definition at line 637 of file blobbox.h.

637 {
638 return num_repeated_sets_ != -1;
639 }

◆ set_limits()

void tesseract::TO_ROW::set_limits ( float  new_min,
float  new_max 
)
inline

Definition at line 628 of file blobbox.h.

630 { // top of row
631 y_min = new_min;
632 y_max = new_max;
633 }

◆ set_line()

void tesseract::TO_ROW::set_line ( float  new_m,
float  new_c,
float  new_error 
)
inline

Definition at line 612 of file blobbox.h.

614 {
615 m = new_m;
616 c = new_c;
617 error = new_error;
618 }

◆ set_num_repeated_sets()

void tesseract::TO_ROW::set_num_repeated_sets ( int  num_sets)
inline

Definition at line 646 of file blobbox.h.

646 {
647 num_repeated_sets_ = num_sets;
648 }

◆ set_parallel_line()

void tesseract::TO_ROW::set_parallel_line ( float  gradient,
float  new_c,
float  new_error 
)
inline

Definition at line 619 of file blobbox.h.

621 {
622 para_c = new_c;
623 para_error = new_error;
624 credibility = blobs.length() - kErrorWeight * new_error;
625 y_origin = new_c / std::sqrt(1 + gradient * gradient);
626 // real intercept
627 }
static const int kErrorWeight
Definition: blobbox.h:557

Member Data Documentation

◆ all_caps

bool tesseract::TO_ROW::all_caps

Definition at line 652 of file blobbox.h.

◆ ascrise

float tesseract::TO_ROW::ascrise

Definition at line 665 of file blobbox.h.

◆ baseline

QSPLINE tesseract::TO_ROW::baseline

Definition at line 676 of file blobbox.h.

◆ body_size

float tesseract::TO_ROW::body_size

Definition at line 667 of file blobbox.h.

◆ char_cells

ICOORDELT_LIST tesseract::TO_ROW::char_cells

Definition at line 675 of file blobbox.h.

◆ descdrop

float tesseract::TO_ROW::descdrop

Definition at line 666 of file blobbox.h.

◆ fixed_pitch

float tesseract::TO_ROW::fixed_pitch

Definition at line 657 of file blobbox.h.

◆ fp_nonsp

float tesseract::TO_ROW::fp_nonsp

Definition at line 659 of file blobbox.h.

◆ fp_space

float tesseract::TO_ROW::fp_space

Definition at line 658 of file blobbox.h.

◆ kern_size

float tesseract::TO_ROW::kern_size

Definition at line 672 of file blobbox.h.

◆ kErrorWeight

const int tesseract::TO_ROW::kErrorWeight = 3
static

Definition at line 557 of file blobbox.h.

◆ max_nonspace

int32_t tesseract::TO_ROW::max_nonspace

Definition at line 670 of file blobbox.h.

◆ merged

bool tesseract::TO_ROW::merged = false

Definition at line 651 of file blobbox.h.

◆ min_space

int32_t tesseract::TO_ROW::min_space

Definition at line 669 of file blobbox.h.

◆ pitch_decision

PITCH_TYPE tesseract::TO_ROW::pitch_decision

Definition at line 656 of file blobbox.h.

◆ pr_nonsp

float tesseract::TO_ROW::pr_nonsp

Definition at line 661 of file blobbox.h.

◆ pr_space

float tesseract::TO_ROW::pr_space

Definition at line 660 of file blobbox.h.

◆ projection

STATS tesseract::TO_ROW::projection

Definition at line 677 of file blobbox.h.

◆ projection_left

int16_t tesseract::TO_ROW::projection_left

Definition at line 654 of file blobbox.h.

◆ projection_right

int16_t tesseract::TO_ROW::projection_right

Definition at line 655 of file blobbox.h.

◆ rep_words

WERD_LIST tesseract::TO_ROW::rep_words

Definition at line 674 of file blobbox.h.

◆ space_size

float tesseract::TO_ROW::space_size

Definition at line 673 of file blobbox.h.

◆ space_threshold

int32_t tesseract::TO_ROW::space_threshold

Definition at line 671 of file blobbox.h.

◆ spacing

float tesseract::TO_ROW::spacing

Definition at line 662 of file blobbox.h.

◆ used_dm_model

bool tesseract::TO_ROW::used_dm_model

Definition at line 653 of file blobbox.h.

◆ xheight

float tesseract::TO_ROW::xheight

Definition at line 663 of file blobbox.h.

◆ xheight_evidence

int tesseract::TO_ROW::xheight_evidence

Definition at line 664 of file blobbox.h.


The documentation for this class was generated from the following files: