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(ICOORD page_tr,
00047 TO_BLOCK_LIST *port_blocks,
00048 float gradient,
00049 FCOORD rotation,
00050 BOOL8 testing_on);
00051 void fix_row_pitch(
00052 TO_ROW *bad_row,
00053 TO_BLOCK *bad_block,
00054 TO_BLOCK_LIST *blocks,
00055 inT32 row_target,
00056 inT32 block_target
00057 );
00058 void compute_block_pitch( TO_BLOCK *block,
00059 FCOORD rotation,
00060 inT32 block_index,
00061 BOOL8 testing_on);
00062 BOOL8 compute_rows_pitch(
00063 TO_BLOCK *block,
00064 inT32 block_index,
00065 BOOL8 testing_on
00066 );
00067 BOOL8 try_doc_fixed(
00068 ICOORD page_tr,
00069 TO_BLOCK_LIST *port_blocks,
00070 float gradient
00071 );
00072 BOOL8 try_block_fixed(
00073 TO_BLOCK *block,
00074 inT32 block_index
00075 );
00076 BOOL8 try_rows_fixed(
00077 TO_BLOCK *block,
00078 inT32 block_index,
00079 BOOL8 testing_on
00080 );
00081 void print_block_counts(
00082 TO_BLOCK *block,
00083 inT32 block_index
00084 );
00085 void count_block_votes(
00086 TO_BLOCK *block,
00087 inT32 &def_fixed,
00088 inT32 &def_prop,
00089 inT32 &maybe_fixed,
00090 inT32 &maybe_prop,
00091 inT32 &corr_fixed,
00092 inT32 &corr_prop,
00093 inT32 &dunno);
00094 BOOL8 row_pitch_stats(
00095 TO_ROW *row,
00096 inT32 maxwidth,
00097 BOOL8 testing_on
00098 );
00099 BOOL8 find_row_pitch(
00100 TO_ROW *row,
00101 inT32 maxwidth,
00102 inT32 dm_gap,
00103 TO_BLOCK *block,
00104 inT32 block_index,
00105 inT32 row_index,
00106 BOOL8 testing_on
00107 );
00108 BOOL8 fixed_pitch_row(
00109 TO_ROW *row,
00110 BLOCK* block,
00111 inT32 block_index
00112 );
00113 BOOL8 count_pitch_stats(
00114 TO_ROW *row,
00115 STATS *gap_stats,
00116 STATS *pitch_stats,
00117 float initial_pitch,
00118 float min_space,
00119 BOOL8 ignore_outsize,
00120 BOOL8 split_outsize,
00121 inT32 dm_gap
00122 );
00123 float tune_row_pitch(
00124 TO_ROW *row,
00125 STATS *projection,
00126 inT16 projection_left,
00127 inT16 projection_right,
00128 float space_size,
00129 float &initial_pitch,
00130 float &best_sp_sd,
00131 inT16 &best_mid_cuts,
00132 ICOORDELT_LIST *best_cells,
00133 BOOL8 testing_on
00134 );
00135 float tune_row_pitch2(
00136 TO_ROW *row,
00137 STATS *projection,
00138 inT16 projection_left,
00139 inT16 projection_right,
00140 float space_size,
00141 float &initial_pitch,
00142 float &best_sp_sd,
00143 inT16 &best_mid_cuts,
00144 ICOORDELT_LIST *best_cells,
00145 BOOL8 testing_on
00146 );
00147 float compute_pitch_sd (
00148 TO_ROW * row,
00149 STATS * projection,
00150 inT16 projection_left,
00151 inT16 projection_right,
00152 float space_size,
00153 float initial_pitch,
00154 float &sp_sd,
00155 inT16 & mid_cuts,
00156 ICOORDELT_LIST * row_cells,
00157 BOOL8 testing_on,
00158 inT16 start = 0,
00159 inT16 end = 0
00160 );
00161 float compute_pitch_sd2 (
00162 TO_ROW * row,
00163 STATS * projection,
00164 inT16 projection_left,
00165 inT16 projection_right,
00166 float initial_pitch,
00167 inT16 & occupation,
00168 inT16 & mid_cuts,
00169 ICOORDELT_LIST * row_cells,
00170 BOOL8 testing_on,
00171 inT16 start = 0,
00172 inT16 end = 0
00173 );
00174 void print_pitch_sd(
00175 TO_ROW *row,
00176 STATS *projection,
00177 inT16 projection_left,
00178 inT16 projection_right,
00179 float space_size,
00180 float initial_pitch
00181 );
00182 void find_repeated_chars(TO_BLOCK *block,
00183 BOOL8 testing_on);
00184 void plot_fp_word(
00185 TO_BLOCK *block,
00186 float pitch,
00187 float nonspace
00188 );
00189 #endif