00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef APPLYBOX_H
00021 #define APPLYBOX_H
00022
00023 #include "varable.h"
00024 #include "ocrblock.h"
00025 #include "ocrrow.h"
00026 #include "notdll.h"
00027 #include "unichar.h"
00028
00029 extern BOOL_VAR_H (applybox_rebalance, TRUE, "Drop dead");
00030 extern INT_VAR_H (applybox_debug, 0, "Debug level");
00031 extern INT_VAR_H (applybox_page, 0, "Page number to apply boxes from");
00032 extern STRING_VAR_H (applybox_test_exclusions, "|",
00033 "Chars ignored for testing");
00034 extern double_VAR_H (applybox_error_band, 0.15, "Err band as fract of xht");
00035 extern STRING_VAR_H(exposure_pattern, "exp",
00036 "Exposure value follows this pattern in the image"
00037 " filename. The name of the image files are expected"
00038 " to be in the form [lang].[fontname].exp[num].tif");
00039
00040 static const int kMinFragmentOutlineArea = 10;
00041
00043 UNICHAR_ID register_char(const char *uch);
00044
00045 void apply_boxes(const STRING& filename,
00046 BLOCK_LIST *block_list
00047 );
00048
00053 void clear_any_old_text(BLOCK_LIST *block_list);
00054
00055 BOOL8 read_next_box(int page,
00056 FILE* box_file,
00057 TBOX *box,
00058 UNICHAR_ID *uch_id);
00059
00060 ROW *find_row_of_box(BLOCK_LIST *block_list,
00061 const TBOX &box,
00062 inT16 &block_id,
00063 inT16 &row_id_to_process);
00064
00065 inT16 resegment_box(ROW *row,
00066 TBOX &box,
00067 UNICHAR_ID uch_id,
00068 inT16 block_id,
00069 inT16 row_id,
00070 inT16 boxfile_lineno,
00071 inT16 boxfile_charno,
00072 inT16 *tgt_char_counts,
00073 bool learn_char_fragments,
00074 bool learning);
00075
00076 void tidy_up(BLOCK_LIST *block_list,
00077 inT16 &ok_char_count,
00078 inT16 &ok_row_count,
00079 inT16 &unlabelled_words,
00080 inT16 *tgt_char_counts,
00081 inT16 &rebalance_count,
00082 UNICHAR_ID *min_uch_id,
00083 inT16 &min_samples,
00084 inT16 &final_labelled_blob_count,
00085 bool learn_character_fragments,
00086 bool learning);
00087
00088 void report_failed_box(inT16 boxfile_lineno,
00089 inT16 boxfile_charno,
00090 TBOX box,
00091 const char *box_ch,
00092 const char *err_msg);
00093
00094 void apply_box_training(const STRING& filename, BLOCK_LIST *block_list);
00095 #endif