wordrec/bestfirst.h

Go to the documentation of this file.
00001 
00021 #ifndef BESTFIRST_H
00022 #define BESTFIRST_H
00023 
00024 /*----------------------------------------------------------------------
00025               I n c l u d e s
00026 ----------------------------------------------------------------------*/
00027 #include "oldheap.h"
00028 #include "closed.h"
00029 #include "choicearr.h"
00030 #include "associate.h"
00031 #include "choices.h"
00032 #include "states.h"
00033 #include "stopper.h"
00034 #include "blobs.h"
00035 #include "tessclas.h"
00036 #include "seam.h"
00037 
00038 /*----------------------------------------------------------------------
00039               T y p e s
00040 ----------------------------------------------------------------------*/
00050 typedef struct
00051 {
00052   HEAP *open_states;
00053   HASH_TABLE closed_states;
00054   STATE *this_state;
00055   STATE *first_state;
00056   STATE *best_state;
00057   int num_joints;
00058   long num_states;
00059   long before_best;
00060   A_CHOICE *best_choice;
00061   A_CHOICE *raw_choice;
00062 } SEARCH_RECORD;
00063 
00064 /*----------------------------------------------------------------------
00065               V a r i a b l e s
00066 ---------------------------------------------------------------------*/
00067 extern int num_seg_states;
00068 extern int num_popped;
00069 
00070 /*----------------------------------------------------------------------
00071               M a c r o s
00072 ---------------------------------------------------------------------*/
00077 #define chunks_gap(chunk_widths,last_chunk)                    \
00078 ((last_chunk < (chunk_widths)->num_chars - 1) ?  \
00079    ((chunk_widths)->widths[last_chunk * 2 + 1]) :  \
00080    (0))
00081 
00082 /*----------------------------------------------------------------------
00083               F u n c t i o n s
00084 ----------------------------------------------------------------------*/
00085 void init_bestfirst_vars(); 
00086 
00087 void best_first_search(CHUNKS_RECORD *chunks_record,
00088                        A_CHOICE *best_choice,
00089                        A_CHOICE *raw_choice,
00090                        STATE *state,
00091                        DANGERR *fixpt,
00092                        STATE *best_state,
00093                        INT32 pass);
00094 
00095 int chunks_width(WIDTH_RECORD *width_record, int start_chunk, int last_chunk); 
00096 
00097 void delete_search(SEARCH_RECORD *the_search); 
00098 
00099 CHOICES_LIST evaluate_chunks(CHUNKS_RECORD *chunks_record,
00100                              SEARCH_STATE search_state,
00101                              STATE *this_state,
00102                              STATE *best_state,
00103                              INT32 pass);
00104 
00105 INT16 evaluate_state(CHUNKS_RECORD *chunks_record,
00106                      SEARCH_RECORD *the_search,
00107                      DANGERR *fixpt,
00108                      STATE *best_state,
00109                      INT32 pass);
00110 
00111 CHOICES_LIST rebuild_current_state(TBLOB *blobs,
00112                                    SEAMS seam_list,
00113                                    STATE *state,
00114                                    CHOICES_LIST old_choices,
00115                                    int fx);
00116 
00117 void expand_node(CHUNKS_RECORD *chunks_record, SEARCH_RECORD *the_search); 
00118 
00119 SEARCH_RECORD *new_search(CHUNKS_RECORD *chunks_record,
00120                           int num_joints,
00121                           A_CHOICE *best_choice,
00122                           A_CHOICE *raw_choice,
00123                           STATE *state);
00124 
00125 STATE *pop_queue(HEAP *queue); 
00126 
00127 void push_queue(HEAP *queue, STATE *state, FLOAT32 priority); 
00128 
00129 void replace_char_widths(CHUNKS_RECORD *chunks_record, SEARCH_STATE state); 
00130 
00131 /*
00132 #if defined(__STDC__) || defined(__cplusplus)
00133 # define _ARGS(s) s
00134 #else
00135 # define _ARGS(s) ()
00136 #endif*/
00137 
00138 /* bestfirst.c
00139 void init_bestfirst_vars
00140   _ARGS((void));
00141 
00142 void best_first_search
00143   _ARGS((CHUNKS_RECORD *chunks_record,
00144   A_CHOICE *best_choice,
00145   A_CHOICE *raw_choice,
00146   STATE *state,
00147   STATE*             best_state,
00148   INT32              pass));
00149 
00150 CHOICES_LIST rebuild_current_state();
00151 
00152 void write_segmentation
00153   _ARGS((char *correct,
00154     CHUNKS_RECORD *chunks_record,
00155   SEARCH_RECORD  *the_search));
00156 
00157 int chunks_width
00158   _ARGS((WIDTH_RECORD *width_record,
00159   int start_chunk,
00160   int last_chunk));
00161 
00162 void delete_search
00163   _ARGS((SEARCH_RECORD *the_search));
00164 
00165 CHOICES_LIST evaluate_chunks
00166   _ARGS((CHUNKS_RECORD *chunks_record,
00167   SEARCH_STATE search_state,
00168   STATE*             this_state,
00169   STATE*             best_state,
00170   INT32              pass));
00171 
00172 INT16 evaluate_state
00173   _ARGS((CHUNKS_RECORD *chunks_record,
00174   SEARCH_RECORD *the_search,
00175   STATE*             best_state,
00176   INT32              pass));
00177 
00178 void expand_node
00179   _ARGS((CHUNKS_RECORD *chunks_record,
00180   SEARCH_RECORD *the_search));
00181 
00182 SEARCH_RECORD *new_search
00183   _ARGS((CHUNKS_RECORD *chunks_record,
00184   int num_joints,
00185   A_CHOICE *best_choice,
00186   A_CHOICE *raw_choice,
00187   STATE *state));
00188 
00189 STATE *pop_queue
00190   _ARGS((HEAP *queue));
00191 
00192 void push_queue
00193   _ARGS((HEAP *queue,
00194   STATE *state,
00195   FLOAT32 priority));
00196 
00197 void replace_char_widths
00198   _ARGS((CHUNKS_RECORD *chunks_record,
00199   SEARCH_STATE state));
00200 #undef _ARGS
00201 */
00202 #endif

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