Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tesseract::ColumnFinder Class Reference

#include <colfind.h>

Inheritance diagram for tesseract::ColumnFinder:
tesseract::TabFind tesseract::AlignedBlob tesseract::BlobGrid tesseract::BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > tesseract::GridBase

Public Member Functions

 ColumnFinder (int gridsize, const ICOORD &bleft, const ICOORD &tright, int resolution, TabVector_LIST *vlines, TabVector_LIST *hlines, int vertical_x, int vertical_y)
 
virtual ~ColumnFinder ()
 
const DENORMdenorm () const
 
const TextlineProjectionprojection () const
 
void SetupAndFilterNoise (Pix *photo_mask_pix, TO_BLOCK *input_block)
 
bool IsVerticallyAlignedText (TO_BLOCK *block, BLOBNBOX_CLIST *osd_blobs)
 
void CorrectOrientation (TO_BLOCK *block, bool vertical_text_lines, int recognition_rotation)
 
int FindBlocks (bool single_column, Pix *scaled_color, int scaled_factor, TO_BLOCK *block, Pix *photo_mask_pix, BLOCK_LIST *blocks, TO_BLOCK_LIST *to_blocks)
 
void GetDeskewVectors (FCOORD *deskew, FCOORD *reskew)
 
void SetEquationDetect (EquationDetectBase *detect)
 
- Public Member Functions inherited from tesseract::TabFind
 TabFind (int gridsize, const ICOORD &bleft, const ICOORD &tright, TabVector_LIST *vlines, int vertical_x, int vertical_y, int resolution)
 
virtual ~TabFind ()
 
void InsertBlobsToGrid (bool h_spread, bool v_spread, BLOBNBOX_LIST *blobs, BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > *grid)
 
bool InsertBlob (bool h_spread, bool v_spread, BLOBNBOX *blob, BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > *grid)
 
void SetBlockRuleEdges (TO_BLOCK *block)
 
void SetBlobRuleEdges (BLOBNBOX_LIST *blobs)
 
int GutterWidth (int bottom_y, int top_y, const TabVector &v, bool ignore_unmergeables, int max_gutter_width, int *required_shift)
 
void GutterWidthAndNeighbourGap (int tab_x, int mean_height, int max_gutter, bool left, BLOBNBOX *bbox, int *gutter_width, int *neighbour_gap)
 
int RightEdgeForBox (const TBOX &box, bool crossing, bool extended)
 
int LeftEdgeForBox (const TBOX &box, bool crossing, bool extended)
 
TabVectorRightTabForBox (const TBOX &box, bool crossing, bool extended)
 
TabVectorLeftTabForBox (const TBOX &box, bool crossing, bool extended)
 
bool CommonWidth (int width)
 
WidthCallbackWidthCB ()
 
const ICOORDimage_origin () const
 
- Public Member Functions inherited from tesseract::AlignedBlob
 AlignedBlob (int gridsize, const ICOORD &bleft, const ICOORD &tright)
 
virtual ~AlignedBlob ()
 
ScrollViewDisplayTabs (const char *window_name, ScrollView *tab_win)
 
TabVectorFindVerticalAlignment (AlignedBlobParams align_params, BLOBNBOX *bbox, int *vertical_x, int *vertical_y)
 
- Public Member Functions inherited from tesseract::BlobGrid
 BlobGrid (int gridsize, const ICOORD &bleft, const ICOORD &tright)
 
virtual ~BlobGrid ()
 
void InsertBlobList (BLOBNBOX_LIST *blobs)
 
- Public Member Functions inherited from tesseract::BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT >
 BBGrid ()
 
 BBGrid (int gridsize, const ICOORD &bleft, const ICOORD &tright)
 
virtual ~BBGrid ()
 
void Init (int gridsize, const ICOORD &bleft, const ICOORD &tright)
 
void Clear ()
 
void ClearGridData (void(*free_method)(BLOBNBOX *))
 
void InsertBBox (bool h_spread, bool v_spread, BLOBNBOX *bbox)
 
void InsertPixPtBBox (int left, int bottom, Pix *pix, BLOBNBOX *bbox)
 
void RemoveBBox (BLOBNBOX *bbox)
 
bool RectangleEmpty (const TBOX &rect)
 
IntGridCountCellElements ()
 
ScrollViewMakeWindow (int x, int y, const char *window_name)
 
void DisplayBoxes (ScrollView *window)
 
void AssertNoDuplicates ()
 
virtual void HandleClick (int x, int y)
 
- Public Member Functions inherited from tesseract::GridBase
 GridBase ()
 
 GridBase (int gridsize, const ICOORD &bleft, const ICOORD &tright)
 
virtual ~GridBase ()
 
void Init (int gridsize, const ICOORD &bleft, const ICOORD &tright)
 
int gridsize () const
 
int gridwidth () const
 
int gridheight () const
 
const ICOORDbleft () const
 
const ICOORDtright () const
 
void GridCoords (int x, int y, int *grid_x, int *grid_y) const
 
void ClipGridCoords (int *x, int *y) const
 

Additional Inherited Members

- Static Public Member Functions inherited from tesseract::TabFind
static bool DifferentSizes (int size1, int size2)
 
static bool VeryDifferentSizes (int size1, int size2)
 
- Static Public Member Functions inherited from tesseract::AlignedBlob
static bool WithinTestRegion (int detail_level, int x, int y)
 
static void IncrementDebugPix ()
 
static const STRINGtextord_debug_pix ()
 
- Protected Member Functions inherited from tesseract::TabFind
TabVector_LIST * vectors ()
 
TabVector_LIST * dead_vectors ()
 
bool FindTabVectors (TabVector_LIST *hlines, BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, int min_gutter_width, ColPartitionGrid *part_grid, FCOORD *deskew, FCOORD *reskew)
 
void DontFindTabVectors (BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, FCOORD *deskew, FCOORD *reskew)
 
void TidyBlobs (TO_BLOCK *block)
 
void SetupTabSearch (int x, int y, int *min_key, int *max_key)
 
ScrollViewDisplayTabVectors (ScrollView *tab_win)
 
ScrollViewFindInitialTabVectors (BLOBNBOX_LIST *image_blobs, int min_gutter_width, TO_BLOCK *block)
 
void ResetForVerticalText (const FCOORD &rotate, const FCOORD &rerotate, TabVector_LIST *horizontal_lines, int *min_gutter_width)
 
void Reset ()
 
void ReflectInYAxis ()
 
- Static Protected Member Functions inherited from tesseract::TabFind
static void RotateBlobList (const FCOORD &rotation, BLOBNBOX_LIST *blobs)
 
- Protected Attributes inherited from tesseract::TabFind
ICOORD vertical_skew_
 
int resolution_
 
- Protected Attributes inherited from tesseract::BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT >
BLOBNBOX_CLIST * grid_
 
- Protected Attributes inherited from tesseract::GridBase
int gridsize_
 
int gridwidth_
 
int gridheight_
 
int gridbuckets_
 
ICOORD bleft_
 
ICOORD tright_
 

Detailed Description

Definition at line 52 of file colfind.h.

Constructor & Destructor Documentation

tesseract::ColumnFinder::ColumnFinder ( int  gridsize,
const ICOORD bleft,
const ICOORD tright,
int  resolution,
TabVector_LIST *  vlines,
TabVector_LIST *  hlines,
int  vertical_x,
int  vertical_y 
)

Definition at line 84 of file colfind.cpp.

89  : TabFind(gridsize, bleft, tright, vlines, vertical_x, vertical_y,
90  resolution),
91  min_gutter_width_(static_cast<int>(kMinGutterWidthGrid * gridsize)),
92  mean_column_gap_(tright.x() - bleft.x()),
93  reskew_(1.0f, 0.0f), rotation_(1.0f, 0.0f), rerotate_(1.0f, 0.0f),
94  best_columns_(NULL), stroke_width_(NULL),
95  part_grid_(gridsize, bleft, tright), nontext_map_(NULL),
96  projection_(resolution),
97  denorm_(NULL), input_blobs_win_(NULL), equation_detect_(NULL) {
98  TabVector_IT h_it(&horizontal_lines_);
99  h_it.add_list_after(hlines);
100 }
inT16 x() const
access function
Definition: points.h:52
int gridsize() const
Definition: bbgrid.h:68
#define NULL
Definition: host.h:144
#define f(xc, yc)
Definition: imgscale.cpp:39
const double kMinGutterWidthGrid
Definition: colfind.cpp:61
TabFind(int gridsize, const ICOORD &bleft, const ICOORD &tright, TabVector_LIST *vlines, int vertical_x, int vertical_y, int resolution)
Definition: tabfind.cpp:89
tesseract::ColumnFinder::~ColumnFinder ( )
virtual

Definition at line 102 of file colfind.cpp.

102  {
103  column_sets_.delete_data_pointers();
104  if (best_columns_ != NULL) {
105  delete [] best_columns_;
106  }
107  if (stroke_width_ != NULL)
108  delete stroke_width_;
109  delete input_blobs_win_;
110  pixDestroy(&nontext_map_);
111  while (denorm_ != NULL) {
112  DENORM* dead_denorm = denorm_;
113  denorm_ = const_cast<DENORM*>(denorm_->predecessor());
114  delete dead_denorm;
115  }
116 
117  // The ColPartitions are destroyed automatically, but any boxes in
118  // the noise_parts_ list are owned and need to be deleted explicitly.
119  ColPartition_IT part_it(&noise_parts_);
120  for (part_it.mark_cycle_pt(); !part_it.cycled_list(); part_it.forward()) {
121  ColPartition* part = part_it.data();
122  part->DeleteBoxes();
123  }
124  // Likewise any boxes in the good_parts_ list need to be deleted.
125  // These are just the image parts. Text parts have already given their
126  // boxes on to the TO_BLOCK, and have empty lists.
127  part_it.set_to_list(&good_parts_);
128  for (part_it.mark_cycle_pt(); !part_it.cycled_list(); part_it.forward()) {
129  ColPartition* part = part_it.data();
130  part->DeleteBoxes();
131  }
132  // Also, any blobs on the image_bblobs_ list need to have their cblobs
133  // deleted. This only happens if there has been an early return from
134  // FindColumns, as in a normal return, the blobs go into the grid and
135  // end up in noise_parts_, good_parts_ or the output blocks.
136  BLOBNBOX_IT bb_it(&image_bblobs_);
137  for (bb_it.mark_cycle_pt(); !bb_it.cycled_list(); bb_it.forward()) {
138  BLOBNBOX* bblob = bb_it.data();
139  delete bblob->cblob();
140  }
141 }
void delete_data_pointers()
const DENORM * predecessor() const
Definition: normalis.h:260
C_BLOB * cblob() const
Definition: blobbox.h:245
#define NULL
Definition: host.h:144

Member Function Documentation

void tesseract::ColumnFinder::CorrectOrientation ( TO_BLOCK block,
bool  vertical_text_lines,
int  recognition_rotation 
)

Definition at line 205 of file colfind.cpp.

207  {
208  const FCOORD anticlockwise90(0.0f, 1.0f);
209  const FCOORD clockwise90(0.0f, -1.0f);
210  const FCOORD rotation180(-1.0f, 0.0f);
211  const FCOORD norotation(1.0f, 0.0f);
212 
213  text_rotation_ = norotation;
214  // Rotate the page to make the text upright, as implied by
215  // recognition_rotation.
216  rotation_ = norotation;
217  if (recognition_rotation == 1) {
218  rotation_ = anticlockwise90;
219  } else if (recognition_rotation == 2) {
220  rotation_ = rotation180;
221  } else if (recognition_rotation == 3) {
222  rotation_ = clockwise90;
223  }
224  // We infer text writing direction to be vertical if there are several
225  // vertical text lines detected, and horizontal if not. But if the page
226  // orientation was determined to be 90 or 270 degrees, the true writing
227  // direction is the opposite of what we inferred.
228  if (recognition_rotation & 1) {
229  vertical_text_lines = !vertical_text_lines;
230  }
231  // If we still believe the writing direction is vertical, we use the
232  // convention of rotating the page ccw 90 degrees to make the text lines
233  // horizontal, and mark the blobs for rotation cw 90 degrees for
234  // classification so that the text order is correct after recognition.
235  if (vertical_text_lines) {
236  rotation_.rotate(anticlockwise90);
237  text_rotation_.rotate(clockwise90);
238  }
239  // Set rerotate_ to the inverse of rotation_.
240  rerotate_ = FCOORD(rotation_.x(), -rotation_.y());
241  if (rotation_.x() != 1.0f || rotation_.y() != 0.0f) {
242  // Rotate all the blobs and tab vectors.
243  RotateBlobList(rotation_, &block->large_blobs);
244  RotateBlobList(rotation_, &block->blobs);
245  RotateBlobList(rotation_, &block->small_blobs);
246  RotateBlobList(rotation_, &block->noise_blobs);
247  TabFind::ResetForVerticalText(rotation_, rerotate_, &horizontal_lines_,
248  &min_gutter_width_);
249  part_grid_.Init(gridsize(), bleft(), tright());
250  // Reset all blobs to initial state and filter by size.
251  // Since they have rotated, the list they belong on could have changed.
252  block->ReSetAndReFilterBlobs();
253  SetBlockRuleEdges(block);
254  stroke_width_->CorrectForRotation(rerotate_, &part_grid_);
255  }
256  if (textord_debug_tabfind) {
257  tprintf("Vertical=%d, orientation=%d, final rotation=(%f, %f)+(%f,%f)\n",
258  vertical_text_lines, recognition_rotation,
259  rotation_.x(), rotation_.y(),
260  text_rotation_.x(), text_rotation_.y());
261  }
262  // Setup the denormalization.
263  ASSERT_HOST(denorm_ == NULL);
264  denorm_ = new DENORM;
265  denorm_->SetupNormalization(NULL, NULL, &rotation_, NULL, NULL, 0,
266  0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
267 }
BLOBNBOX_LIST noise_blobs
Definition: blobbox.h:737
BLOBNBOX_LIST blobs
Definition: blobbox.h:735
void SetBlockRuleEdges(TO_BLOCK *block)
Definition: tabfind.cpp:158
int gridsize() const
Definition: bbgrid.h:68
#define NULL
Definition: host.h:144
#define f(xc, yc)
Definition: imgscale.cpp:39
int textord_debug_tabfind
Definition: alignedblob.cpp:28
void ResetForVerticalText(const FCOORD &rotate, const FCOORD &rerotate, TabVector_LIST *horizontal_lines, int *min_gutter_width)
Definition: tabfind.cpp:1329
BLOBNBOX_LIST small_blobs
Definition: blobbox.h:738
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:41
void rotate(const FCOORD vec)
Definition: ipoints.h:471
const ICOORD & tright() const
Definition: bbgrid.h:80
Definition: points.h:189
static void RotateBlobList(const FCOORD &rotation, BLOBNBOX_LIST *blobs)
Definition: tabfind.cpp:1259
void SetupNormalization(const BLOCK *block, const ROW *row, const FCOORD *rotation, const DENORM *predecessor, const DENORM_SEG *segs, int num_segs, float x_origin, float y_origin, float x_scale, float y_scale, float final_xshift, float final_yshift)
Definition: normalis.cpp:143
void CorrectForRotation(const FCOORD &rerotation, ColPartitionGrid *part_grid)
void ReSetAndReFilterBlobs()
Definition: blobbox.cpp:952
BLOBNBOX_LIST large_blobs
Definition: blobbox.h:739
float y() const
Definition: points.h:212
const ICOORD & bleft() const
Definition: bbgrid.h:77
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
Definition: bbgrid.h:444
#define ASSERT_HOST(x)
Definition: errcode.h:84
float x() const
Definition: points.h:209
const DENORM* tesseract::ColumnFinder::denorm ( ) const
inline

Definition at line 66 of file colfind.h.

66  {
67  return denorm_;
68  }
int tesseract::ColumnFinder::FindBlocks ( bool  single_column,
Pix *  scaled_color,
int  scaled_factor,
TO_BLOCK block,
Pix *  photo_mask_pix,
BLOCK_LIST *  blocks,
TO_BLOCK_LIST *  to_blocks 
)

Definition at line 284 of file colfind.cpp.

287  {
288  pixOr(photo_mask_pix, photo_mask_pix, nontext_map_);
289  stroke_width_->FindLeaderPartitions(input_block, &part_grid_);
290  stroke_width_->RemoveLineResidue(&big_parts_);
291  FindInitialTabVectors(NULL, min_gutter_width_, input_block);
292  SetBlockRuleEdges(input_block);
293  stroke_width_->GradeBlobsIntoPartitions(rerotate_, input_block, nontext_map_,
294  denorm_, &projection_,
295  &part_grid_, &big_parts_);
296  ImageFind::FindImagePartitions(photo_mask_pix, rotation_, rerotate_,
297  input_block, this, &part_grid_, &big_parts_);
298  ImageFind::TransferImagePartsToImageMask(rerotate_, &part_grid_,
299  photo_mask_pix);
300  ImageFind::FindImagePartitions(photo_mask_pix, rotation_, rerotate_,
301  input_block, this, &part_grid_, &big_parts_);
302  part_grid_.ReTypeBlobs(&image_bblobs_);
303  TidyBlobs(input_block);
304  Reset();
305  // TODO(rays) need to properly handle big_parts_.
306  ColPartition_IT p_it(&big_parts_);
307  for (p_it.mark_cycle_pt(); !p_it.cycled_list(); p_it.forward())
308  p_it.data()->DisownBoxes();
309  big_parts_.clear();
310  delete stroke_width_;
311  stroke_width_ = NULL;
312 
313  // A note about handling right-to-left scripts (Hebrew/Arabic):
314  // The columns must be reversed and come out in right-to-left instead of
315  // the normal left-to-right order. Because the left-to-right ordering
316  // is implicit in many data structures, it is simpler to fool the algorithms
317  // into thinking they are dealing with left-to-right text.
318  // To do this, we reflect the needed data in the y-axis and then reflect
319  // the blocks back after they have been created. This is a temporary
320  // arrangment that is confined to this function only, so the reflection
321  // is completely invisible in the output blocks.
322  // The only objects reflected are:
323  // The vertical separator lines that have already been found;
324  // The bounding boxes of all BLOBNBOXES on all lists on the input_block
325  // plus the image_bblobs. The outlines are not touched, since they are
326  // not looked at.
327  bool input_is_rtl = input_block->block->right_to_left();
328  if (input_is_rtl) {
329  // Reflect the vertical separator lines (member of TabFind).
330  ReflectInYAxis();
331  // Reflect the blob boxes.
332  ReflectForRtl(input_block, &image_bblobs_);
333  part_grid_.ReflectInYAxis();
334  }
335 
336  if (single_column) {
337  // No tab stops needed. Just the grid that FindTabVectors makes.
338  DontFindTabVectors(&image_bblobs_, input_block, &deskew_, &reskew_);
339  } else {
340  SetBlockRuleEdges(input_block);
341  // Find the tab stops, estimate skew, and deskew the tabs, blobs and
342  // part_grid_.
343  FindTabVectors(&horizontal_lines_, &image_bblobs_, input_block,
344  min_gutter_width_, &part_grid_, &deskew_, &reskew_);
345  // Add the deskew to the denorm_.
346  DENORM* new_denorm = new DENORM;
347  new_denorm->SetupNormalization(NULL, NULL, &deskew_, denorm_, NULL, 0,
348  0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
349  denorm_ = new_denorm;
350  }
351  SetBlockRuleEdges(input_block);
352  part_grid_.SetTabStops(this);
353 
354  // Make the column_sets_.
355  if (!MakeColumns(single_column)) {
356  tprintf("Empty page!!\n");
357  return 0; // This is an empty page.
358  }
359 
360  // Refill the grid using rectangular spreading, and get the benefit
361  // of the completed tab vectors marking the rule edges of each blob.
362  Clear();
363  #ifndef GRAPHICS_DISABLED
365  ScrollView* rej_win = MakeWindow(500, 300, "Rejected blobs");
366  input_block->plot_graded_blobs(rej_win);
367  }
368  #endif // GRAPHICS_DISABLED
369  InsertBlobsToGrid(false, false, &image_bblobs_, this);
370  InsertBlobsToGrid(true, true, &input_block->blobs, this);
371 
372  part_grid_.GridFindMargins(best_columns_);
373  // Split and merge the partitions by looking at local neighbours.
374  GridSplitPartitions();
375  // Resolve unknown partitions by adding to an existing partition, fixing
376  // the type, or declaring them noise.
377  part_grid_.GridFindMargins(best_columns_);
378  GridMergePartitions();
379  // Insert any unused noise blobs that are close enough to an appropriate
380  // partition.
381  InsertRemainingNoise(input_block);
382  // Add horizontal line separators as partitions.
383  GridInsertHLinePartitions();
384  GridInsertVLinePartitions();
385  // Recompute margins based on a local neighbourhood search.
386  part_grid_.GridFindMargins(best_columns_);
387  SetPartitionTypes();
389  ScrollView* part_win = MakeWindow(100, 300, "InitialPartitions");
390  part_grid_.DisplayBoxes(part_win);
391  DisplayTabVectors(part_win);
392  }
393 
394  if (equation_detect_) {
395  equation_detect_->FindEquationParts(&part_grid_, best_columns_);
396  }
398  TableFinder table_finder;
399  table_finder.Init(gridsize(), bleft(), tright());
400  table_finder.set_resolution(resolution_);
401  table_finder.set_left_to_right_language(
402  !input_block->block->right_to_left());
403  // Copy cleaned partitions from part_grid_ to clean_part_grid_ and
404  // insert dot-like noise into period_grid_
405  table_finder.InsertCleanPartitions(&part_grid_, input_block);
406  // Get Table Regions
407  table_finder.LocateTables(&part_grid_, best_columns_, WidthCB(), reskew_);
408  }
409  GridRemoveUnderlinePartitions();
410  part_grid_.DeleteUnknownParts(input_block);
411 
412  // Build the partitions into chains that belong in the same block and
413  // refine into one-to-one links, then smooth the types within each chain.
414  part_grid_.FindPartitionPartners();
415  part_grid_.FindFigureCaptions();
416  part_grid_.RefinePartitionPartners(true);
417  SmoothPartnerRuns();
418 
419  #ifndef GRAPHICS_DISABLED
421  ScrollView* window = MakeWindow(400, 300, "Partitions");
423  window->Image(AlignedBlob::textord_debug_pix().string(),
424  image_origin().x(), image_origin().y());
425  part_grid_.DisplayBoxes(window);
427  DisplayTabVectors(window);
428  if (window != NULL && textord_tabfind_show_partitions > 1) {
429  delete window->AwaitEvent(SVET_DESTROY);
430  }
431  }
432  #endif // GRAPHICS_DISABLED
433  part_grid_.AssertNoDuplicates();
434  // Ownership of the ColPartitions moves from part_sets_ to part_grid_ here,
435  // and ownership of the BLOBNBOXes moves to the ColPartitions.
436  // (They were previously owned by the block or the image_bblobs list.)
437  ReleaseBlobsAndCleanupUnused(input_block);
438  // Ownership of the ColPartitions moves from part_grid_ to good_parts_ and
439  // noise_parts_ here. In text blocks, ownership of the BLOBNBOXes moves
440  // from the ColPartitions to the output TO_BLOCK. In non-text, the
441  // BLOBNBOXes stay with the ColPartitions and get deleted in the destructor.
442  TransformToBlocks(blocks, to_blocks);
443  if (textord_debug_tabfind) {
444  tprintf("Found %d blocks, %d to_blocks\n",
445  blocks->length(), to_blocks->length());
446  }
447 
448  DisplayBlocks(blocks);
449  RotateAndReskewBlocks(input_is_rtl, to_blocks);
450  int result = 0;
451  #ifndef GRAPHICS_DISABLED
452  if (blocks_win_ != NULL) {
453  bool waiting = false;
454  do {
455  waiting = false;
456  SVEvent* event = blocks_win_->AwaitEvent(SVET_ANY);
457  if (event->type == SVET_INPUT && event->parameter != NULL) {
458  if (*event->parameter == 'd')
459  result = -1;
460  else
461  blocks->clear();
462  } else if (event->type == SVET_DESTROY) {
463  blocks_win_ = NULL;
464  } else {
465  waiting = true;
466  }
467  delete event;
468  } while (waiting);
469  }
470  #endif // GRAPHICS_DISABLED
471  return result;
472 }
SVEvent * AwaitEvent(SVEventType type)
Definition: scrollview.cpp:444
ScrollView * FindInitialTabVectors(BLOBNBOX_LIST *image_blobs, int min_gutter_width, TO_BLOCK *block)
Definition: tabfind.cpp:542
void ReTypeBlobs(BLOBNBOX_LIST *im_blobs)
WidthCallback * WidthCB()
Definition: tabfind.h:167
virtual int FindEquationParts(ColPartitionGrid *part_grid, ColPartitionSet **best_columns)=0
bool FindTabVectors(TabVector_LIST *hlines, BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, int min_gutter_width, ColPartitionGrid *part_grid, FCOORD *deskew, FCOORD *reskew)
Definition: tabfind.cpp:447
void SetBlockRuleEdges(TO_BLOCK *block)
Definition: tabfind.cpp:158
bool textord_debug_images
Definition: alignedblob.cpp:34
bool textord_tabfind_show_initial_partitions
Definition: colfind.cpp:67
void DisplayBoxes(ScrollView *window)
Definition: bbgrid.h:613
int gridsize() const
Definition: bbgrid.h:68
#define NULL
Definition: host.h:144
void DontFindTabVectors(BLOBNBOX_LIST *image_blobs, TO_BLOCK *block, FCOORD *deskew, FCOORD *reskew)
Definition: tabfind.cpp:480
#define f(xc, yc)
Definition: imgscale.cpp:39
void SetTabStops(TabFind *tabgrid)
int textord_debug_tabfind
Definition: alignedblob.cpp:28
static void TransferImagePartsToImageMask(const FCOORD &rerotation, ColPartitionGrid *part_grid, Pix *image_mask)
Definition: imagefind.cpp:1222
void GradeBlobsIntoPartitions(const FCOORD &rerotation, TO_BLOCK *block, Pix *nontext_pix, const DENORM *denorm, TextlineProjection *projection, ColPartitionGrid *part_grid, ColPartition_LIST *big_parts)
bool textord_debug_printable
Definition: alignedblob.cpp:35
void FindLeaderPartitions(TO_BLOCK *block, ColPartitionGrid *part_grid)
void InsertBlobsToGrid(bool h_spread, bool v_spread, BLOBNBOX_LIST *blobs, BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > *grid)
Definition: tabfind.cpp:116
void GridFindMargins(ColPartitionSet **best_columns)
void Image(struct Pix *image, int x_pos, int y_pos)
Definition: scrollview.cpp:768
bool textord_tabfind_find_tables
Definition: colfind.cpp:74
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:41
void AssertNoDuplicates()
Definition: bbgrid.h:638
const ICOORD & tright() const
Definition: bbgrid.h:80
void DeleteUnknownParts(TO_BLOCK *block)
void SetupNormalization(const BLOCK *block, const ROW *row, const FCOORD *rotation, const DENORM *predecessor, const DENORM_SEG *segs, int num_segs, float x_origin, float y_origin, float x_scale, float y_scale, float final_xshift, float final_yshift)
Definition: normalis.cpp:143
static const STRING & textord_debug_pix()
Definition: alignedblob.h:112
ScrollView * DisplayTabVectors(ScrollView *tab_win)
Definition: tabfind.cpp:525
bool textord_tabfind_show_reject_blobs
Definition: colfind.cpp:69
static void FindImagePartitions(Pix *image_pix, const FCOORD &rotation, const FCOORD &rerotation, TO_BLOCK *block, TabFind *tab_grid, ColPartitionGrid *part_grid, ColPartition_LIST *big_parts)
Definition: imagefind.cpp:1275
const ICOORD & image_origin() const
Definition: tabfind.h:174
void TidyBlobs(TO_BLOCK *block)
Definition: tabfind.cpp:493
const ICOORD & bleft() const
Definition: bbgrid.h:77
void RemoveLineResidue(ColPartition_LIST *big_part_list)
void RefinePartitionPartners(bool get_desperate)
int textord_tabfind_show_partitions
Definition: colfind.cpp:71
ScrollView * MakeWindow(int x, int y, const char *window_name)
void tesseract::ColumnFinder::GetDeskewVectors ( FCOORD deskew,
FCOORD reskew 
)

Definition at line 475 of file colfind.cpp.

475  {
476  *reskew = reskew_;
477  *deskew = reskew_;
478  deskew->set_y(-deskew->y());
479 }
float y() const
Definition: points.h:212
void set_y(float yin)
rewrite function
Definition: points.h:220
bool tesseract::ColumnFinder::IsVerticallyAlignedText ( TO_BLOCK block,
BLOBNBOX_CLIST *  osd_blobs 
)

Definition at line 189 of file colfind.cpp.

190  {
191  return stroke_width_->TestVerticalTextDirection(block, osd_blobs);
192 }
bool TestVerticalTextDirection(TO_BLOCK *block, BLOBNBOX_CLIST *osd_blobs)
const TextlineProjection* tesseract::ColumnFinder::projection ( ) const
inline

Definition at line 69 of file colfind.h.

69  {
70  return &projection_;
71  }
void tesseract::ColumnFinder::SetEquationDetect ( EquationDetectBase detect)

Definition at line 481 of file colfind.cpp.

481  {
482  equation_detect_ = detect;
483 }
void tesseract::ColumnFinder::SetupAndFilterNoise ( Pix *  photo_mask_pix,
TO_BLOCK input_block 
)

Definition at line 150 of file colfind.cpp.

151  {
152  part_grid_.Init(gridsize(), bleft(), tright());
153  if (stroke_width_ != NULL)
154  delete stroke_width_;
155  stroke_width_ = new StrokeWidth(gridsize(), bleft(), tright());
156  min_gutter_width_ = static_cast<int>(kMinGutterWidthGrid * gridsize());
157  input_block->ReSetAndReFilterBlobs();
158  #ifndef GRAPHICS_DISABLED
160  input_blobs_win_ = MakeWindow(0, 0, "Filtered Input Blobs");
161  input_block->plot_graded_blobs(input_blobs_win_);
162  }
163  #endif // GRAPHICS_DISABLED
164  SetBlockRuleEdges(input_block);
165  pixDestroy(&nontext_map_);
166  // Run a preliminary strokewidth neighbour detection on the medium blobs.
167  stroke_width_->SetNeighboursOnMediumBlobs(input_block);
168  CCNonTextDetect nontext_detect(gridsize(), bleft(), tright());
169  // Remove obvious noise and make the initial non-text map.
170  nontext_map_ = nontext_detect.ComputeNonTextMask(textord_debug_tabfind,
171  photo_mask_pix, input_block);
172  // TODO(rays) experiment with making broken CJK fixing dependent on the
173  // language, and keeping the merged blobs on output instead of exploding at
174  // ColPartition::MakeBlock.
175  stroke_width_->FindTextlineDirectionAndFixBrokenCJK(true, input_block);
176  // Clear the strokewidth grid ready for rotation or leader finding.
177  stroke_width_->Clear();
178 }
void plot_graded_blobs(ScrollView *to_win)
Definition: blobbox.cpp:999
bool textord_tabfind_show_blocks
Definition: colfind.cpp:73
void SetBlockRuleEdges(TO_BLOCK *block)
Definition: tabfind.cpp:158
int gridsize() const
Definition: bbgrid.h:68
#define NULL
Definition: host.h:144
int textord_debug_tabfind
Definition: alignedblob.cpp:28
void Clear()
Definition: bbgrid.h:455
void FindTextlineDirectionAndFixBrokenCJK(bool cjk_merge, TO_BLOCK *input_block)
const ICOORD & tright() const
Definition: bbgrid.h:80
void SetNeighboursOnMediumBlobs(TO_BLOCK *block)
void ReSetAndReFilterBlobs()
Definition: blobbox.cpp:952
const ICOORD & bleft() const
Definition: bbgrid.h:77
const double kMinGutterWidthGrid
Definition: colfind.cpp:61
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
Definition: bbgrid.h:444
ScrollView * MakeWindow(int x, int y, const char *window_name)

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