~vcs-imports/tesseract-ocr/trunk

« back to all changes in this revision

Viewing changes to ccmain/applybox.cpp

  • Committer: theraysmith at gmail
  • Date: 2014-04-23 22:52:05 UTC
  • Revision ID: svn-v4:d0cd1f9f-072b-0410-8dd7-cf729c803f20:trunk:1060
Added ability for box files to store spaces and newlines

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
  return xheights.median();
192
192
}
193
193
 
194
 
// Builds a PAGE_RES from the block_list in the way required for ApplyBoxes:
195
 
// All fuzzy spaces are removed, and all the words are maximally chopped.
196
 
PAGE_RES* Tesseract::SetupApplyBoxes(const GenericVector<TBOX>& boxes,
197
 
                                     BLOCK_LIST *block_list) {
 
194
// Any row xheight that is significantly different from the median is set
 
195
// to the median.
 
196
void Tesseract::PreenXHeights(BLOCK_LIST *block_list) {
198
197
  double median_xheight = MedianXHeight(block_list);
199
198
  double max_deviation = kMaxXHeightDeviationFraction * median_xheight;
200
199
  // Strip all fuzzy space markers to simplify the PAGE_RES.
212
211
        }
213
212
        row->set_x_height(static_cast<float>(median_xheight));
214
213
      }
 
214
    }
 
215
  }
 
216
}
 
217
 
 
218
// Builds a PAGE_RES from the block_list in the way required for ApplyBoxes:
 
219
// All fuzzy spaces are removed, and all the words are maximally chopped.
 
220
PAGE_RES* Tesseract::SetupApplyBoxes(const GenericVector<TBOX>& boxes,
 
221
                                     BLOCK_LIST *block_list) {
 
222
  PreenXHeights(block_list);
 
223
  // Strip all fuzzy space markers to simplify the PAGE_RES.
 
224
  BLOCK_IT b_it(block_list);
 
225
  for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
 
226
    BLOCK* block = b_it.data();
 
227
    ROW_IT r_it(block->row_list());
 
228
    for (r_it.mark_cycle_pt(); !r_it.cycled_list(); r_it.forward ()) {
 
229
      ROW* row = r_it.data();
215
230
      WERD_IT w_it(row->word_list());
216
231
      for (w_it.mark_cycle_pt(); !w_it.cycled_list(); w_it.forward()) {
217
232
        WERD* word = w_it.data();
434
449
    if (!box.major_overlap(block->bounding_box()))
435
450
      continue;
436
451
    ROW_IT r_it(block->row_list());
437
 
    for (r_it.mark_cycle_pt(); !r_it.cycled_list(); r_it.forward ()) {
 
452
    for (r_it.mark_cycle_pt(); !r_it.cycled_list(); r_it.forward()) {
438
453
      ROW* row = r_it.data();
439
454
      if (!box.major_overlap(row->bounding_box()))
440
455
        continue;