tesseract  4.1.1
TO_ROW Class Reference

#include <blobbox.h>

Inheritance diagram for TO_ROW:
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 ELIST2_LINK
 ELIST2_LINK ()
 
 ELIST2_LINK (const ELIST2_LINK &)
 
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 544 of file blobbox.h.

Constructor & Destructor Documentation

◆ TO_ROW() [1/2]

TO_ROW::TO_ROW ( )
inline

Definition at line 549 of file blobbox.h.

549  {
550  clear();
551  } //empty

◆ TO_ROW() [2/2]

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

Definition at line 689 of file blobbox.cpp.

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

Member Function Documentation

◆ add_blob()

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

Definition at line 733 of file blobbox.cpp.

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

◆ believability()

float TO_ROW::believability ( ) const
inline

Definition at line 586 of file blobbox.h.

586  { //baseline goodness
587  return credibility;
588  }

◆ blob_list()

BLOBNBOX_LIST* TO_ROW::blob_list ( )
inline

Definition at line 600 of file blobbox.h.

600  { //get list
601  return &blobs;
602  }

◆ clear_rep_chars_marked()

void TO_ROW::clear_rep_chars_marked ( )
inline

Definition at line 634 of file blobbox.h.

634  {
635  num_repeated_sets_ = -1;
636  }

◆ compute_vertical_projection()

void TO_ROW::compute_vertical_projection ( )

Definition at line 796 of file blobbox.cpp.

796  { //project whole row
797  TBOX row_box; //bound of row
798  BLOBNBOX *blob; //current blob
799  TBOX blob_box; //bounding box
800  BLOBNBOX_IT blob_it = blob_list ();
801 
802  if (blob_it.empty ())
803  return;
804  row_box = blob_it.data ()->bounding_box ();
805  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ())
806  row_box += blob_it.data ()->bounding_box ();
807 
809  row_box.right () + PROJECTION_MARGIN);
810  projection_left = row_box.left () - PROJECTION_MARGIN;
812  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
813  blob = blob_it.data();
814  if (blob->cblob() != nullptr)
816  }
817 }

◆ initial_min_y()

float TO_ROW::initial_min_y ( ) const
inline

Definition at line 568 of file blobbox.h.

568  {
569  return initial_y_min;
570  }

◆ insert_blob()

void TO_ROW::insert_blob ( BLOBNBOX blob)

Definition at line 769 of file blobbox.cpp.

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

◆ intercept()

float TO_ROW::intercept ( ) const
inline

Definition at line 589 of file blobbox.h.

589  { //real parallel_c
590  return y_origin;
591  }

◆ line_c()

float TO_ROW::line_c ( ) const
inline

Definition at line 574 of file blobbox.h.

574  {
575  return c;
576  }

◆ line_error()

float TO_ROW::line_error ( ) const
inline

Definition at line 577 of file blobbox.h.

577  {
578  return error;
579  }

◆ line_m()

float TO_ROW::line_m ( ) const
inline

Definition at line 571 of file blobbox.h.

571  { //access to line fit
572  return m;
573  }

◆ max_y()

float TO_ROW::max_y ( ) const
inline

Definition at line 559 of file blobbox.h.

559  { //access function
560  return y_max;
561  }

◆ mean_y()

float TO_ROW::mean_y ( ) const
inline

Definition at line 565 of file blobbox.h.

565  {
566  return (y_min + y_max) / 2.0f;
567  }

◆ min_y()

float TO_ROW::min_y ( ) const
inline

Definition at line 562 of file blobbox.h.

562  {
563  return y_min;
564  }

◆ num_repeated_sets()

int TO_ROW::num_repeated_sets ( ) const
inline

Definition at line 637 of file blobbox.h.

637  {
638  return num_repeated_sets_;
639  }

◆ parallel_c()

float TO_ROW::parallel_c ( ) const
inline

Definition at line 580 of file blobbox.h.

580  {
581  return para_c;
582  }

◆ parallel_error()

float TO_ROW::parallel_error ( ) const
inline

Definition at line 583 of file blobbox.h.

583  {
584  return para_error;
585  }

◆ print()

void TO_ROW::print ( ) const

Definition at line 717 of file blobbox.cpp.

717  {
718  tprintf("pitch=%d, fp=%g, fps=%g, fpns=%g, prs=%g, prns=%g,"
719  " spacing=%g xh=%g y_origin=%g xev=%d, asc=%g, desc=%g,"
720  " body=%g, minsp=%d maxnsp=%d, thr=%d kern=%g sp=%g\n",
724  space_size);
725 }

◆ rep_chars_marked()

bool TO_ROW::rep_chars_marked ( ) const
inline

Definition at line 631 of file blobbox.h.

631  {
632  return num_repeated_sets_ != -1;
633  }

◆ set_limits()

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

Definition at line 622 of file blobbox.h.

624  { //top of row
625  y_min = new_min;
626  y_max = new_max;
627  }

◆ set_line()

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

Definition at line 604 of file blobbox.h.

607  {
608  m = new_m;
609  c = new_c;
610  error = new_error;
611  }

◆ set_num_repeated_sets()

void TO_ROW::set_num_repeated_sets ( int  num_sets)
inline

Definition at line 640 of file blobbox.h.

640  {
641  num_repeated_sets_ = num_sets;
642  }

◆ set_parallel_line()

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

Definition at line 612 of file blobbox.h.

615  {
616  para_c = new_c;
617  para_error = new_error;
618  credibility = blobs.length() - kErrorWeight * new_error;
619  y_origin = new_c / std::sqrt(1 + gradient * gradient);
620  //real intercept
621  }

Member Data Documentation

◆ all_caps

bool TO_ROW::all_caps

Definition at line 646 of file blobbox.h.

◆ ascrise

float TO_ROW::ascrise

Definition at line 659 of file blobbox.h.

◆ baseline

QSPLINE TO_ROW::baseline

Definition at line 670 of file blobbox.h.

◆ body_size

float TO_ROW::body_size

Definition at line 661 of file blobbox.h.

◆ char_cells

ICOORDELT_LIST TO_ROW::char_cells

Definition at line 669 of file blobbox.h.

◆ descdrop

float TO_ROW::descdrop

Definition at line 660 of file blobbox.h.

◆ fixed_pitch

float TO_ROW::fixed_pitch

Definition at line 651 of file blobbox.h.

◆ fp_nonsp

float TO_ROW::fp_nonsp

Definition at line 653 of file blobbox.h.

◆ fp_space

float TO_ROW::fp_space

Definition at line 652 of file blobbox.h.

◆ kern_size

float TO_ROW::kern_size

Definition at line 666 of file blobbox.h.

◆ kErrorWeight

const int TO_ROW::kErrorWeight = 3
static

Definition at line 547 of file blobbox.h.

◆ max_nonspace

int32_t TO_ROW::max_nonspace

Definition at line 664 of file blobbox.h.

◆ merged

bool TO_ROW::merged = false

Definition at line 645 of file blobbox.h.

◆ min_space

int32_t TO_ROW::min_space

Definition at line 663 of file blobbox.h.

◆ pitch_decision

PITCH_TYPE TO_ROW::pitch_decision

Definition at line 650 of file blobbox.h.

◆ pr_nonsp

float TO_ROW::pr_nonsp

Definition at line 655 of file blobbox.h.

◆ pr_space

float TO_ROW::pr_space

Definition at line 654 of file blobbox.h.

◆ projection

STATS TO_ROW::projection

Definition at line 671 of file blobbox.h.

◆ projection_left

int16_t TO_ROW::projection_left

Definition at line 648 of file blobbox.h.

◆ projection_right

int16_t TO_ROW::projection_right

Definition at line 649 of file blobbox.h.

◆ rep_words

WERD_LIST TO_ROW::rep_words

Definition at line 668 of file blobbox.h.

◆ space_size

float TO_ROW::space_size

Definition at line 667 of file blobbox.h.

◆ space_threshold

int32_t TO_ROW::space_threshold

Definition at line 665 of file blobbox.h.

◆ spacing

float TO_ROW::spacing

Definition at line 656 of file blobbox.h.

◆ used_dm_model

bool TO_ROW::used_dm_model

Definition at line 647 of file blobbox.h.

◆ xheight

float TO_ROW::xheight

Definition at line 657 of file blobbox.h.

◆ xheight_evidence

int TO_ROW::xheight_evidence

Definition at line 658 of file blobbox.h.


The documentation for this class was generated from the following files:
TBOX
Definition: rect.h:34
TO_ROW::projection
STATS projection
Definition: blobbox.h:671
TO_ROW::projection_left
int16_t projection_left
Definition: blobbox.h:648
TO_ROW::min_space
int32_t min_space
Definition: blobbox.h:663
BLOBNBOX::bounding_box
const TBOX & bounding_box() const
Definition: blobbox.h:230
TO_ROW::projection_right
int16_t projection_right
Definition: blobbox.h:649
TBOX::right
int16_t right() const
Definition: rect.h:79
TO_ROW::spacing
float spacing
Definition: blobbox.h:656
STATS::set_range
bool set_range(int32_t min_bucket_value, int32_t max_bucket_value_plus_1)
Definition: statistc.cpp:56
TO_ROW::descdrop
float descdrop
Definition: blobbox.h:660
BLOBNBOX
Definition: blobbox.h:144
TBOX::left
int16_t left() const
Definition: rect.h:72
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:35
TO_ROW::fp_space
float fp_space
Definition: blobbox.h:652
TO_ROW::kErrorWeight
static const int kErrorWeight
Definition: blobbox.h:547
TO_ROW::pr_nonsp
float pr_nonsp
Definition: blobbox.h:655
TO_ROW::pr_space
float pr_space
Definition: blobbox.h:654
TO_ROW::pitch_decision
PITCH_TYPE pitch_decision
Definition: blobbox.h:650
TO_ROW::space_size
float space_size
Definition: blobbox.h:667
TO_ROW::blob_list
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:600
TO_ROW::ascrise
float ascrise
Definition: blobbox.h:659
TO_ROW::fp_nonsp
float fp_nonsp
Definition: blobbox.h:653
TO_ROW::fixed_pitch
float fixed_pitch
Definition: blobbox.h:651
TO_ROW::body_size
float body_size
Definition: blobbox.h:661
BLOBNBOX::cblob
C_BLOB * cblob() const
Definition: blobbox.h:268
TO_ROW::space_threshold
int32_t space_threshold
Definition: blobbox.h:665
TO_ROW::xheight
float xheight
Definition: blobbox.h:657
PROJECTION_MARGIN
#define PROJECTION_MARGIN
Definition: blobbox.cpp:37
TO_ROW::xheight_evidence
int xheight_evidence
Definition: blobbox.h:658
TO_ROW::max_nonspace
int32_t max_nonspace
Definition: blobbox.h:664
vertical_cblob_projection
void vertical_cblob_projection(C_BLOB *blob, STATS *stats)
Definition: blobbox.cpp:868
TO_ROW::kern_size
float kern_size
Definition: blobbox.h:666