tesseract  4.1.0
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
 
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::TO_ROW ( )
inline

Definition at line 560 of file blobbox.h.

560  {
561  clear();
562  } //empty
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

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 }
float TO_ROW::believability ( ) const
inline

Definition at line 597 of file blobbox.h.

597  { //baseline goodness
598  return credibility;
599  }
BLOBNBOX_LIST* TO_ROW::blob_list ( )
inline

Definition at line 611 of file blobbox.h.

611  { //get list
612  return &blobs;
613  }
void TO_ROW::clear_rep_chars_marked ( )
inline

Definition at line 645 of file blobbox.h.

645  {
646  num_repeated_sets_ = -1;
647  }
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 }
Definition: rect.h:34
int16_t projection_right
Definition: blobbox.h:660
C_BLOB * cblob() const
Definition: blobbox.h:268
int16_t projection_left
Definition: blobbox.h:659
void vertical_cblob_projection(C_BLOB *blob, STATS *stats)
Definition: blobbox.cpp:868
int16_t right() const
Definition: rect.h:79
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:611
int16_t left() const
Definition: rect.h:72
STATS projection
Definition: blobbox.h:682
bool set_range(int32_t min_bucket_value, int32_t max_bucket_value_plus_1)
Definition: statistc.cpp:62
#define PROJECTION_MARGIN
Definition: blobbox.cpp:37
float TO_ROW::initial_min_y ( ) const
inline

Definition at line 579 of file blobbox.h.

579  {
580  return initial_y_min;
581  }
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 }
const TBOX & bounding_box() const
Definition: blobbox.h:230
int16_t left() const
Definition: rect.h:72
float TO_ROW::intercept ( ) const
inline

Definition at line 600 of file blobbox.h.

600  { //real parallel_c
601  return y_origin;
602  }
float TO_ROW::line_c ( ) const
inline

Definition at line 585 of file blobbox.h.

585  {
586  return c;
587  }
float TO_ROW::line_error ( ) const
inline

Definition at line 588 of file blobbox.h.

588  {
589  return error;
590  }
float TO_ROW::line_m ( ) const
inline

Definition at line 582 of file blobbox.h.

582  { //access to line fit
583  return m;
584  }
float TO_ROW::max_y ( ) const
inline

Definition at line 570 of file blobbox.h.

570  { //access function
571  return y_max;
572  }
float TO_ROW::mean_y ( ) const
inline

Definition at line 576 of file blobbox.h.

576  {
577  return (y_min + y_max) / 2.0f;
578  }
float TO_ROW::min_y ( ) const
inline

Definition at line 573 of file blobbox.h.

573  {
574  return y_min;
575  }
int TO_ROW::num_repeated_sets ( ) const
inline

Definition at line 648 of file blobbox.h.

648  {
649  return num_repeated_sets_;
650  }
float TO_ROW::parallel_c ( ) const
inline

Definition at line 591 of file blobbox.h.

591  {
592  return para_c;
593  }
float TO_ROW::parallel_error ( ) const
inline

Definition at line 594 of file blobbox.h.

594  {
595  return para_error;
596  }
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 }
PITCH_TYPE pitch_decision
Definition: blobbox.h:661
float xheight
Definition: blobbox.h:668
float pr_space
Definition: blobbox.h:665
float descdrop
Definition: blobbox.h:671
float fp_space
Definition: blobbox.h:663
float spacing
Definition: blobbox.h:667
int32_t min_space
Definition: blobbox.h:674
int32_t space_threshold
Definition: blobbox.h:676
float fixed_pitch
Definition: blobbox.h:662
int xheight_evidence
Definition: blobbox.h:669
float space_size
Definition: blobbox.h:678
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:36
float fp_nonsp
Definition: blobbox.h:664
float pr_nonsp
Definition: blobbox.h:666
float ascrise
Definition: blobbox.h:670
int32_t max_nonspace
Definition: blobbox.h:675
float kern_size
Definition: blobbox.h:677
float body_size
Definition: blobbox.h:672
bool TO_ROW::rep_chars_marked ( ) const
inline

Definition at line 642 of file blobbox.h.

642  {
643  return num_repeated_sets_ != -1;
644  }
void TO_ROW::set_limits ( float  new_min,
float  new_max 
)
inline

Definition at line 633 of file blobbox.h.

635  { //top of row
636  y_min = new_min;
637  y_max = new_max;
638  }
void TO_ROW::set_line ( float  new_m,
float  new_c,
float  new_error 
)
inline

Definition at line 615 of file blobbox.h.

618  {
619  m = new_m;
620  c = new_c;
621  error = new_error;
622  }
void TO_ROW::set_num_repeated_sets ( int  num_sets)
inline

Definition at line 651 of file blobbox.h.

651  {
652  num_repeated_sets_ = num_sets;
653  }
void TO_ROW::set_parallel_line ( float  gradient,
float  new_c,
float  new_error 
)
inline

Definition at line 623 of file blobbox.h.

626  {
627  para_c = new_c;
628  para_error = new_error;
629  credibility = blobs.length() - kErrorWeight * new_error;
630  y_origin = new_c / std::sqrt(1 + gradient * gradient);
631  //real intercept
632  }
static const int kErrorWeight
Definition: blobbox.h:558

Member Data Documentation

bool TO_ROW::all_caps

Definition at line 657 of file blobbox.h.

float TO_ROW::ascrise

Definition at line 670 of file blobbox.h.

QSPLINE TO_ROW::baseline

Definition at line 681 of file blobbox.h.

float TO_ROW::body_size

Definition at line 672 of file blobbox.h.

ICOORDELT_LIST TO_ROW::char_cells

Definition at line 680 of file blobbox.h.

float TO_ROW::descdrop

Definition at line 671 of file blobbox.h.

float TO_ROW::fixed_pitch

Definition at line 662 of file blobbox.h.

float TO_ROW::fp_nonsp

Definition at line 664 of file blobbox.h.

float TO_ROW::fp_space

Definition at line 663 of file blobbox.h.

float TO_ROW::kern_size

Definition at line 677 of file blobbox.h.

const int TO_ROW::kErrorWeight = 3
static

Definition at line 558 of file blobbox.h.

int32_t TO_ROW::max_nonspace

Definition at line 675 of file blobbox.h.

bool TO_ROW::merged

Definition at line 656 of file blobbox.h.

int32_t TO_ROW::min_space

Definition at line 674 of file blobbox.h.

PITCH_TYPE TO_ROW::pitch_decision

Definition at line 661 of file blobbox.h.

float TO_ROW::pr_nonsp

Definition at line 666 of file blobbox.h.

float TO_ROW::pr_space

Definition at line 665 of file blobbox.h.

STATS TO_ROW::projection

Definition at line 682 of file blobbox.h.

int16_t TO_ROW::projection_left

Definition at line 659 of file blobbox.h.

int16_t TO_ROW::projection_right

Definition at line 660 of file blobbox.h.

WERD_LIST TO_ROW::rep_words

Definition at line 679 of file blobbox.h.

float TO_ROW::space_size

Definition at line 678 of file blobbox.h.

int32_t TO_ROW::space_threshold

Definition at line 676 of file blobbox.h.

float TO_ROW::spacing

Definition at line 667 of file blobbox.h.

bool TO_ROW::used_dm_model

Definition at line 658 of file blobbox.h.

float TO_ROW::xheight

Definition at line 668 of file blobbox.h.

int TO_ROW::xheight_evidence

Definition at line 669 of file blobbox.h.


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