00001 00019 #ifndef PAGERES_H 00020 #define PAGERES_H 00021 00022 #include "elst.h" 00023 #include "ocrblock.h" 00024 #include "ocrrow.h" 00025 #include "werd.h" 00026 #include "ratngs.h" 00027 #include "rejctmap.h" 00028 #include "notdll.h" 00029 #include "notdll.h" 00030 00031 /* Forward declarations */ 00032 00033 class BLOCK_RES; 00034 00035 ELISTIZEH (BLOCK_RES) CLISTIZEH (BLOCK_RES) 00036 class ROW_RES; 00037 00038 ELISTIZEH (ROW_RES) 00039 class WERD_RES; 00040 00041 ELISTIZEH (WERD_RES) 00042 00047 class PAGE_RES // page result 00048 { 00049 public: 00051 INT32 char_count; 00053 INT32 rej_count; 00055 BLOCK_RES_LIST block_res_list; 00057 BOOL8 rejected; 00058 00059 PAGE_RES() { 00060 } //empty constructor 00061 00062 PAGE_RES( //simple constructor 00063 BLOCK_LIST *block_list); //real blocks 00064 00065 ~PAGE_RES () { //destructor 00066 } 00067 }; 00068 00073 class BLOCK_RES:public ELIST_LINK //page block result 00074 { 00075 public: 00077 BLOCK * block; 00079 INT32 char_count; 00081 INT32 rej_count; 00082 INT16 font_class; 00084 INT16 row_count; 00086 float x_height; 00088 BOOL8 font_assigned; 00090 BOOL8 bold; 00092 BOOL8 italic; 00093 00095 ROW_RES_LIST row_res_list; 00096 00097 BLOCK_RES() { 00098 } // empty constructor 00099 00100 BLOCK_RES( //simple constructor 00101 BLOCK *the_block); //real block 00102 00103 ~BLOCK_RES () { //destructor 00104 } 00105 }; 00106 00113 class ROW_RES:public ELIST_LINK //row result 00114 { 00115 public: 00117 ROW * row; 00119 INT32 char_count; 00121 INT32 rej_count; 00123 INT32 whole_word_rej_count; 00124 WERD_RES_LIST word_res_list; 00125 float font_class_score; 00126 INT16 font_class; // 00127 INT32 italic; 00128 INT32 bold; 00130 INT8 font1; 00132 INT8 font1_count; 00133 // secondary font 00134 INT8 font2; 00136 INT8 font2_count; 00137 00138 ROW_RES() { 00139 } //empty constructor 00140 00141 ROW_RES( //simple constructor 00142 ROW *the_row); //real row 00143 00144 ~ROW_RES () { //destructor 00145 } 00146 }; 00147 00152 enum CRUNCH_MODE 00153 { 00154 CR_NONE, 00155 CR_KEEP_SPACE, 00156 CR_LOOSE_SPACE, 00157 CR_DELETE 00158 }; 00159 00164 class WERD_RES:public ELIST_LINK //word result 00165 { 00166 public: 00167 // non-bln (baseline normalized?) real word 00168 WERD *word; 00169 // bln best choice 00170 WERD *outword; 00171 00172 //segmentation 00174 DENORM denorm; 00176 WERD_CHOICE *best_choice; 00178 WERD_CHOICE *raw_choice; 00180 WERD_CHOICE *ep_choice; 00182 REJMAP reject_map; 00193 BOOL8 tess_failed; 00195 BOOL8 tess_accepted; 00197 BOOL8 tess_would_adapt; 00199 BOOL8 done; 00200 INT8 italic; 00201 INT8 bold; 00203 INT8 font1; 00205 INT8 font1_count; 00207 INT8 font2; 00209 INT8 font2_count; 00211 CRUNCH_MODE unlv_crunch_mode; 00213 float x_height; 00215 float caps_height; 00217 BOOL8 guessed_x_ht; 00219 BOOL8 guessed_caps_ht; 00240 BOOL8 combination; 00242 BOOL8 part_of_combo; 00244 BOOL8 reject_spaces; 00245 00246 WERD_RES() { 00247 } //empty constructor 00248 00249 WERD_RES( //simple constructor 00250 WERD *the_word) { //real word 00251 word = the_word; 00252 outword = NULL; 00253 best_choice = NULL; 00254 raw_choice = NULL; 00255 ep_choice = NULL; 00256 tess_failed = FALSE; 00257 tess_accepted = FALSE; 00258 tess_would_adapt = FALSE; 00259 done = FALSE; 00260 unlv_crunch_mode = CR_NONE; 00261 italic = FALSE; 00262 bold = FALSE; 00263 font1 = -1; 00264 font1_count = 0; 00265 font2 = -1; 00266 font2_count = 0; 00267 x_height = 0.0; 00268 caps_height = 0.0; 00269 guessed_x_ht = TRUE; 00270 guessed_caps_ht = TRUE; 00271 combination = FALSE; 00272 part_of_combo = FALSE; 00273 reject_spaces = FALSE; 00274 } 00275 WERD_RES( //constr from WERD_RES 00276 const WERD_RES &source) { 00277 *this = source; //see operator= 00278 } 00279 00280 ~WERD_RES (); //destructor 00281 00282 WERD_RES & operator= ( //assign word res 00283 const WERD_RES & source); //from this 00284 00285 void copy_on( //copy blobs onto word 00286 WERD_RES *word_res) { //from this word 00287 word->set_flag (W_EOL, word_res->word->flag (W_EOL)); 00288 word->copy_on (word_res->word); 00289 } 00290 }; 00291 00296 class PAGE_RES_IT 00297 { 00298 public: 00299 PAGE_RES * page_res; // page being iterated 00300 00301 PAGE_RES_IT() { 00302 } //empty contructor 00303 00304 PAGE_RES_IT( //empty contructor 00305 PAGE_RES *the_page_res) { //page result 00306 page_res = the_page_res; 00307 restart_page(); //ready to scan 00308 } 00309 00310 WERD_RES *restart_page(); //get ready 00311 00312 WERD_RES *internal_forward( //get next word 00313 BOOL8 new_block); 00314 00315 WERD_RES *forward() { //get next word 00316 return internal_forward (FALSE); 00317 } 00318 00319 WERD_RES *forward_block(); //get first word in 00320 //next non-empty block 00321 WERD_RES *prev_word() { //previous word 00322 return prev_word_res; 00323 } 00324 ROW_RES *prev_row() { //row of prev word 00325 return prev_row_res; 00326 } 00327 BLOCK_RES *prev_block() { //block of prev word 00328 return prev_block_res; 00329 } 00330 WERD_RES *word() { //current word 00331 return word_res; 00332 } 00333 ROW_RES *row() { //row of current word 00334 return row_res; 00335 } 00336 BLOCK_RES *block() { //block of cur. word 00337 return block_res; 00338 } 00339 WERD_RES *next_word() { //next word 00340 return next_word_res; 00341 } 00342 ROW_RES *next_row() { //row of next word 00343 return next_row_res; 00344 } 00345 BLOCK_RES *next_block() { //block of next word 00346 return next_block_res; 00347 } 00348 void rej_stat_word(); //for page/block/row 00349 00350 private: 00351 WERD_RES * prev_word_res; // previous word 00352 ROW_RES *prev_row_res; // row of prev word 00353 BLOCK_RES *prev_block_res; // block of prev word 00354 00355 WERD_RES *word_res; // current word 00356 ROW_RES *row_res; // row of current word 00357 BLOCK_RES *block_res; // block of cur. word 00358 00359 WERD_RES *next_word_res; // next word 00360 ROW_RES *next_row_res; // row of next word 00361 BLOCK_RES *next_block_res; // block of next word 00362 00363 BLOCK_RES_IT block_res_it; // iterators 00364 ROW_RES_IT row_res_it; 00365 WERD_RES_IT word_res_it; 00366 }; 00367 #endif