00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TOPITCH_H
00021 #define TOPITCH_H
00022
00023 #include "blobbox.h"
00024 #include "notdll.h"
00025
00026 namespace tesseract {
00027 class Tesseract;
00028 }
00029 extern BOOL_VAR_H (textord_debug_pitch_test, FALSE,
00030 "Debug on fixed pitch test");
00031 extern BOOL_VAR_H (textord_debug_pitch_metric, FALSE,
00032 "Write full metric stuff");
00033 extern BOOL_VAR_H (textord_show_row_cuts, FALSE, "Draw row-level cuts");
00034 extern BOOL_VAR_H (textord_show_page_cuts, FALSE, "Draw page-level cuts");
00035 extern BOOL_VAR_H (textord_pitch_cheat, FALSE,
00036 "Use correct answer for fixed/prop");
00037 extern BOOL_VAR_H (textord_blockndoc_fixed, TRUE,
00038 "Attempt whole doc/block fixed pitch");
00039 extern BOOL_VAR_H (textord_fast_pitch_test, FALSE,
00040 "Do even faster pitch algorithm");
00041 extern double_VAR_H (textord_projection_scale, 0.125,
00042 "Ding rate for mid-cuts");
00043 extern double_VAR_H (textord_balance_factor, 2.0,
00044 "Ding rate for unbalanced char cells");
00045
00046 void compute_fixed_pitch(
00047 ICOORD page_tr,
00048 TO_BLOCK_LIST *port_blocks,
00049 float gradient,
00050 FCOORD rotation,
00051 BOOL8 testing_on,
00052 tesseract::Tesseract* tess
00053 );
00054 void fix_row_pitch(
00055 TO_ROW *bad_row,
00056 TO_BLOCK *bad_block,
00057 TO_BLOCK_LIST *blocks,
00058 inT32 row_target,
00059 inT32 block_target
00060 );
00061 void compute_block_pitch(
00062 TO_BLOCK *block,
00063 FCOORD rotation,
00064 inT32 block_index,
00065 BOOL8 testing_on,
00066 tesseract::Tesseract* tess
00067 );
00068 BOOL8 compute_rows_pitch(
00069 TO_BLOCK *block,
00070 inT32 block_index,
00071 BOOL8 testing_on
00072 );
00073 BOOL8 try_doc_fixed(
00074 ICOORD page_tr,
00075 TO_BLOCK_LIST *port_blocks,
00076 float gradient
00077 );
00078 BOOL8 try_block_fixed(
00079 TO_BLOCK *block,
00080 inT32 block_index
00081 );
00082 BOOL8 try_rows_fixed(
00083 TO_BLOCK *block,
00084 inT32 block_index,
00085 BOOL8 testing_on
00086 );
00087 void print_block_counts(
00088 TO_BLOCK *block,
00089 inT32 block_index
00090 );
00091 void count_block_votes(
00092 TO_BLOCK *block,
00093 inT32 &def_fixed,
00094 inT32 &def_prop,
00095 inT32 &maybe_fixed,
00096 inT32 &maybe_prop,
00097 inT32 &corr_fixed,
00098 inT32 &corr_prop,
00099 inT32 &dunno);
00100 BOOL8 row_pitch_stats(
00101 TO_ROW *row,
00102 inT32 maxwidth,
00103 BOOL8 testing_on
00104 );
00105 BOOL8 find_row_pitch(
00106 TO_ROW *row,
00107 inT32 maxwidth,
00108 inT32 dm_gap,
00109 TO_BLOCK *block,
00110 inT32 block_index,
00111 inT32 row_index,
00112 BOOL8 testing_on
00113 );
00114 BOOL8 fixed_pitch_row(
00115 TO_ROW *row,
00116 inT32 block_index
00117 );
00118 BOOL8 count_pitch_stats(
00119 TO_ROW *row,
00120 STATS *gap_stats,
00121 STATS *pitch_stats,
00122 float initial_pitch,
00123 float min_space,
00124 BOOL8 ignore_outsize,
00125 BOOL8 split_outsize,
00126 inT32 dm_gap
00127 );
00128 float tune_row_pitch(
00129 TO_ROW *row,
00130 STATS *projection,
00131 inT16 projection_left,
00132 inT16 projection_right,
00133 float space_size,
00134 float &initial_pitch,
00135 float &best_sp_sd,
00136 inT16 &best_mid_cuts,
00137 ICOORDELT_LIST *best_cells,
00138 BOOL8 testing_on
00139 );
00140 float tune_row_pitch2(
00141 TO_ROW *row,
00142 STATS *projection,
00143 inT16 projection_left,
00144 inT16 projection_right,
00145 float space_size,
00146 float &initial_pitch,
00147 float &best_sp_sd,
00148 inT16 &best_mid_cuts,
00149 ICOORDELT_LIST *best_cells,
00150 BOOL8 testing_on
00151 );
00152 float compute_pitch_sd (
00153 TO_ROW * row,
00154 STATS * projection,
00155 inT16 projection_left,
00156 inT16 projection_right,
00157 float space_size,
00158 float initial_pitch,
00159 float &sp_sd,
00160 inT16 & mid_cuts,
00161 ICOORDELT_LIST * row_cells,
00162 BOOL8 testing_on,
00163 inT16 start = 0,
00164 inT16 end = 0
00165 );
00166 float compute_pitch_sd2 (
00167 TO_ROW * row,
00168 STATS * projection,
00169 inT16 projection_left,
00170 inT16 projection_right,
00171 float initial_pitch,
00172 inT16 & occupation,
00173 inT16 & mid_cuts,
00174 ICOORDELT_LIST * row_cells,
00175 BOOL8 testing_on,
00176 inT16 start = 0,
00177 inT16 end = 0
00178 );
00179 void print_pitch_sd(
00180 TO_ROW *row,
00181 STATS *projection,
00182 inT16 projection_left,
00183 inT16 projection_right,
00184 float space_size,
00185 float initial_pitch
00186 );
00187 int sort_floats2(
00188 const void *arg1,
00189 const void *arg2);
00190 void find_repeated_chars(
00191 TO_BLOCK *block,
00192 BOOL8 testing_on,
00193 tesseract::Tesseract* tess
00194 );
00195 void plot_fp_word(
00196 TO_BLOCK *block,
00197 float pitch,
00198 float nonspace
00199 );
00200 #endif