tesseract  4.1.1
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 138 of file pageres.h.

Constructor & Destructor Documentation

◆ ROW_RES() [1/2]

ROW_RES::ROW_RES ( )
default

◆ ROW_RES() [2/2]

ROW_RES::ROW_RES ( bool  merge_similar_words,
ROW the_row 
)

Definition at line 120 of file pageres.cpp.

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

◆ ~ROW_RES()

ROW_RES::~ROW_RES ( )
default

Member Data Documentation

◆ char_count

int32_t ROW_RES::char_count

Definition at line 141 of file pageres.h.

◆ rej_count

int32_t ROW_RES::rej_count

Definition at line 142 of file pageres.h.

◆ row

ROW* ROW_RES::row

Definition at line 140 of file pageres.h.

◆ whole_word_rej_count

int32_t ROW_RES::whole_word_rej_count

Definition at line 143 of file pageres.h.

◆ word_res_list

WERD_RES_LIST ROW_RES::word_res_list

Definition at line 144 of file pageres.h.


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