tesseract  4.1.0
ROW_RES Class Reference

#include <pageres.h>

Inheritance diagram for ROW_RES:
ELIST_LINK

Public Member Functions

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

Public Attributes

ROWrow
 
int32_t char_count
 
int32_t rej_count
 
int32_t whole_word_rej_count
 
WERD_RES_LIST word_res_list
 

Detailed Description

Definition at line 140 of file pageres.h.

Constructor & Destructor Documentation

ROW_RES::ROW_RES ( )
default
ROW_RES::ROW_RES ( bool  merge_similar_words,
ROW the_row 
)

Definition at line 122 of file pageres.cpp.

122  {
123  WERD_IT word_it(the_row->word_list());
124  WERD_RES_IT word_res_it(&word_res_list);
125  WERD_RES *combo = nullptr; // current combination of fuzzies
126  WERD *copy_word;
127 
128  char_count = 0;
129  rej_count = 0;
131 
132  row = the_row;
133  bool add_next_word = false;
134  TBOX union_box;
135  float line_height = the_row->x_height() + the_row->ascenders() -
136  the_row->descenders();
137  for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
138  auto* word_res = new WERD_RES(word_it.data());
139  word_res->x_height = the_row->x_height();
140  if (add_next_word) {
141  ASSERT_HOST(combo != nullptr);
142  // We are adding this word to the combination.
143  word_res->part_of_combo = true;
144  combo->copy_on(word_res);
145  } else if (merge_similar_words) {
146  union_box = word_res->word->bounding_box();
147  add_next_word = !word_res->word->flag(W_REP_CHAR) &&
148  union_box.height() <= line_height * kMaxWordSizeRatio;
149  word_res->odd_size = !add_next_word;
150  }
151  WERD* next_word = word_it.data_relative(1);
152  if (merge_similar_words) {
153  if (add_next_word && !next_word->flag(W_REP_CHAR)) {
154  // Next word will be added on if all of the following are true:
155  // Not a rep char.
156  // Box height small enough.
157  // Union box height small enough.
158  // Horizontal gap small enough.
159  TBOX next_box = next_word->bounding_box();
160  int prev_right = union_box.right();
161  union_box += next_box;
162  if (next_box.height() > line_height * kMaxWordSizeRatio ||
163  union_box.height() > line_height * kMaxLineSizeRatio ||
164  next_box.left() > prev_right + line_height * kMaxWordGapRatio) {
165  add_next_word = false;
166  }
167  }
168  next_word->set_flag(W_FUZZY_NON, add_next_word);
169  } else {
170  add_next_word = next_word->flag(W_FUZZY_NON);
171  }
172  if (add_next_word) {
173  if (combo == nullptr) {
174  copy_word = new WERD;
175  *copy_word = *(word_it.data()); // deep copy
176  combo = new WERD_RES(copy_word);
177  combo->x_height = the_row->x_height();
178  combo->combination = true;
179  word_res_it.add_to_end(combo);
180  }
181  word_res->part_of_combo = true;
182  } else {
183  combo = nullptr;
184  }
185  word_res_it.add_to_end(word_res);
186  }
187 }
Definition: werd.h:56
float x_height() const
Definition: ocrrow.h:64
Definition: rect.h:34
fuzzy nonspace
Definition: werd.h:40
WERD_RES_LIST word_res_list
Definition: pageres.h:146
int32_t char_count
Definition: pageres.h:143
int32_t whole_word_rej_count
Definition: pageres.h:145
bool combination
Definition: pageres.h:333
repeated character
Definition: werd.h:38
const double kMaxWordGapRatio
Definition: pageres.cpp:60
int16_t height() const
Definition: rect.h:108
float descenders() const
Definition: ocrrow.h:85
void copy_on(WERD_RES *word_res)
Definition: pageres.h:661
int16_t right() const
Definition: rect.h:79
TBOX bounding_box() const
Definition: werd.cpp:148
#define ASSERT_HOST(x)
Definition: errcode.h:88
int16_t left() const
Definition: rect.h:72
const double kMaxWordSizeRatio
Definition: pageres.cpp:56
const double kMaxLineSizeRatio
Definition: pageres.cpp:58
WERD_LIST * word_list()
Definition: ocrrow.h:55
bool flag(WERD_FLAGS mask) const
Definition: werd.h:117
int32_t rej_count
Definition: pageres.h:144
ROW * row
Definition: pageres.h:142
float x_height
Definition: pageres.h:310
void set_flag(WERD_FLAGS mask, bool value)
Definition: werd.h:118
float ascenders() const
Definition: ocrrow.h:82
ROW_RES::~ROW_RES ( )
default

Member Data Documentation

int32_t ROW_RES::char_count

Definition at line 143 of file pageres.h.

int32_t ROW_RES::rej_count

Definition at line 144 of file pageres.h.

ROW* ROW_RES::row

Definition at line 142 of file pageres.h.

int32_t ROW_RES::whole_word_rej_count

Definition at line 145 of file pageres.h.

WERD_RES_LIST ROW_RES::word_res_list

Definition at line 146 of file pageres.h.


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