ccmain/werdit.h File Reference

#include "varable.h"
#include "ocrblock.h"
#include "notdll.h"

Go to the source code of this file.

Classes

Functions


Function Documentation

WERD* make_pseudo_word ( BLOCK_LIST *  block_list,
BOX selection_box,
BLOCK *&  pseudo_block,
ROW *&  pseudo_row 
)

Make all the blobs inside a selection into a single [fake] word.

Parameters:
block_list blocks to check
selection_box block of selection
pseudo_block ?
pseudo_row row of selection
Returns:
word
Note:
The word is always a copy and needs to be deleted.

Definition at line 128 of file werdit.cpp.

References WERD::blob_list(), PBLOB::bounding_box(), WERD::bounding_box(), ROW::bounding_box(), NULL, BOX::overlap(), WERD::poly_copy(), ROW::word_list(), and ROW::x_height().

Referenced by recog_pseudo_word().

00133                         {
00134   BLOCK_IT block_it(block_list); 
00135   BLOCK *block;
00136   ROW_IT row_it;
00137   ROW *row;
00138   WERD_IT word_it;
00139   WERD *word;
00140   PBLOB_IT blob_it;
00141   PBLOB *blob;
00142   PBLOB_LIST new_blobs;          //list of gathered blobs
00143                                  //iterator
00144   PBLOB_IT new_blob_it = &new_blobs;
00145   WERD *pseudo_word;             //fabricated word
00146   WERD *poly_word;               //poly copy of word
00147   //  WERD         *larc_word;     //linearc copy
00148 
00149   for (block_it.mark_cycle_pt ();
00150   !block_it.cycled_list (); block_it.forward ()) {
00151     block = block_it.data ();
00152     if (block->bounding_box ().overlap (selection_box)) {
00153       pseudo_block = block;
00154       row_it.set_to_list (block->row_list ());
00155       for (row_it.mark_cycle_pt ();
00156       !row_it.cycled_list (); row_it.forward ()) {
00157         row = row_it.data ();
00158         if (row->bounding_box ().overlap (selection_box)) {
00159           word_it.set_to_list (row->word_list ());
00160           for (word_it.mark_cycle_pt ();
00161           !word_it.cycled_list (); word_it.forward ()) {
00162             word = word_it.data ();
00163             if (word->bounding_box ().overlap (selection_box)) {
00164               //  if (wordit_linearc && !word->flag(W_POLYGON))
00165               //  {
00166               //     larc_word=word->larc_copy(row->x_height());
00167               //     poly_word=larc_word->poly_copy(row->x_height());
00168               //     delete larc_word;
00169               //  }
00170               //   else
00171               poly_word = word->poly_copy (row->x_height ());
00172               blob_it.set_to_list (poly_word->blob_list ());
00173               for (blob_it.mark_cycle_pt ();
00174               !blob_it.cycled_list (); blob_it.forward ()) {
00175                 blob = blob_it.data ();
00176                 if (blob->bounding_box ().
00177                 overlap (selection_box)) {
00178                   new_blob_it.add_after_then_move (blob_it.extract ());
00179                   pseudo_row = row; //steal off list
00180                 }
00181               }
00182               delete poly_word;  //get rid of it
00183             }
00184           }
00185         }
00186       }
00187     }
00188   }
00189   if (!new_blobs.empty ()) {
00190     pseudo_word = new WERD (&new_blobs, 1, NULL); //make new word
00191   }
00192   else
00193     pseudo_word = NULL;
00194   return pseudo_word;
00195 }


Generated on Wed Feb 28 19:49:16 2007 for Tesseract by  doxygen 1.5.1