tesseract  4.00.00dev
ROW_RES Class Reference

#include <pageres.h>

Inheritance diagram for ROW_RES:
ELIST_LINK

Public Member Functions

 ROW_RES ()
 
 ROW_RES (bool merge_similar_words, ROW *the_row)
 
 ~ROW_RES ()
 
- Public Member Functions inherited from ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Public Attributes

ROWrow
 
inT32 char_count
 
inT32 rej_count
 
inT32 whole_word_rej_count
 
WERD_RES_LIST word_res_list
 

Detailed Description

Definition at line 125 of file pageres.h.

Constructor & Destructor Documentation

◆ ROW_RES() [1/2]

ROW_RES::ROW_RES ( )
inline

Definition at line 133 of file pageres.h.

133  {
134  } // empty constructor

◆ ROW_RES() [2/2]

ROW_RES::ROW_RES ( bool  merge_similar_words,
ROW the_row 
)

Definition at line 110 of file pageres.cpp.

110  {
111  WERD_IT word_it(the_row->word_list());
112  WERD_RES_IT word_res_it(&word_res_list);
113  WERD_RES *combo = NULL; // current combination of fuzzies
114  WERD *copy_word;
115 
116  char_count = 0;
117  rej_count = 0;
119 
120  row = the_row;
121  bool add_next_word = false;
122  TBOX union_box;
123  float line_height = the_row->x_height() + the_row->ascenders() -
124  the_row->descenders();
125  for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
126  WERD_RES* word_res = new WERD_RES(word_it.data());
127  word_res->x_height = the_row->x_height();
128  if (add_next_word) {
129  ASSERT_HOST(combo != NULL);
130  // We are adding this word to the combination.
131  word_res->part_of_combo = TRUE;
132  combo->copy_on(word_res);
133  } else if (merge_similar_words) {
134  union_box = word_res->word->bounding_box();
135  add_next_word = !word_res->word->flag(W_REP_CHAR) &&
136  union_box.height() <= line_height * kMaxWordSizeRatio;
137  word_res->odd_size = !add_next_word;
138  }
139  WERD* next_word = word_it.data_relative(1);
140  if (merge_similar_words) {
141  if (add_next_word && !next_word->flag(W_REP_CHAR)) {
142  // Next word will be added on if all of the following are true:
143  // Not a rep char.
144  // Box height small enough.
145  // Union box height small enough.
146  // Horizontal gap small enough.
147  TBOX next_box = next_word->bounding_box();
148  int prev_right = union_box.right();
149  union_box += next_box;
150  if (next_box.height() > line_height * kMaxWordSizeRatio ||
151  union_box.height() > line_height * kMaxLineSizeRatio ||
152  next_box.left() > prev_right + line_height * kMaxWordGapRatio) {
153  add_next_word = false;
154  }
155  }
156  next_word->set_flag(W_FUZZY_NON, add_next_word);
157  } else {
158  add_next_word = next_word->flag(W_FUZZY_NON);
159  }
160  if (add_next_word) {
161  if (combo == NULL) {
162  copy_word = new WERD;
163  *copy_word = *(word_it.data()); // deep copy
164  combo = new WERD_RES(copy_word);
165  combo->x_height = the_row->x_height();
166  combo->combination = TRUE;
167  word_res_it.add_to_end(combo);
168  }
169  word_res->part_of_combo = TRUE;
170  } else {
171  combo = NULL;
172  }
173  word_res_it.add_to_end(word_res);
174  }
175 }
const double kMaxWordGapRatio
Definition: pageres.cpp:48
inT32 rej_count
Definition: pageres.h:129
#define TRUE
Definition: capi.h:45
const double kMaxLineSizeRatio
Definition: pageres.cpp:46
void set_flag(WERD_FLAGS mask, BOOL8 value)
Definition: werd.h:129
ROW * row
Definition: pageres.h:127
WERD_LIST * word_list()
Definition: ocrrow.h:52
float x_height() const
Definition: ocrrow.h:61
TBOX bounding_box() const
Definition: werd.cpp:160
#define ASSERT_HOST(x)
Definition: errcode.h:84
BOOL8 flag(WERD_FLAGS mask) const
Definition: werd.h:128
inT16 left() const
Definition: rect.h:68
void copy_on(WERD_RES *word_res)
Definition: pageres.h:644
BOOL8 combination
Definition: pageres.h:318
inT32 whole_word_rej_count
Definition: pageres.h:130
inT32 char_count
Definition: pageres.h:128
bool odd_size
Definition: pageres.h:284
BOOL8 part_of_combo
Definition: pageres.h:319
float ascenders() const
Definition: ocrrow.h:79
Definition: rect.h:30
const double kMaxWordSizeRatio
Definition: pageres.cpp:44
inT16 height() const
Definition: rect.h:104
WERD * word
Definition: pageres.h:175
inT16 right() const
Definition: rect.h:75
WERD_RES_LIST word_res_list
Definition: pageres.h:131
Definition: werd.h:60
float x_height
Definition: pageres.h:295
float descenders() const
Definition: ocrrow.h:82

◆ ~ROW_RES()

ROW_RES::~ROW_RES ( )
inline

Definition at line 138 of file pageres.h.

138  { // destructor
139  }

Member Data Documentation

◆ char_count

inT32 ROW_RES::char_count

Definition at line 128 of file pageres.h.

◆ rej_count

inT32 ROW_RES::rej_count

Definition at line 129 of file pageres.h.

◆ row

ROW* ROW_RES::row

Definition at line 127 of file pageres.h.

◆ whole_word_rej_count

inT32 ROW_RES::whole_word_rej_count

Definition at line 130 of file pageres.h.

◆ word_res_list

WERD_RES_LIST ROW_RES::word_res_list

Definition at line 131 of file pageres.h.


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