39 int parent_path_length,
41 float max_char_wh_ratio,
52 tprintf(
"AssociateUtils::ComputeStats() for col=%d, row=%d%s\n",
53 col, row, fixed_pitch ?
" (fixed pitch)" :
"");
58 if (fixed_pitch && blob_row != NULL) {
69 tprintf(
"normalizing height = %g (scale %g xheight %g ascenders %g)\n",
74 float wh_ratio = word_res->
GetBlobsWidth(col, row) / normalizing_height;
75 if (wh_ratio > max_char_wh_ratio) stats->
bad_shape =
true;
80 int negative_gap_sum = 0;
81 for (
int c = col; c < row; ++c) {
83 (gap > 0) ? stats->
gap_sum += gap : negative_gap_sum += gap;
87 tprintf(
"wh_ratio=%g (max_char_wh_ratio=%g) gap_sum=%d %s\n",
88 wh_ratio, max_char_wh_ratio, stats->
gap_sum,
99 float left_gap = word_res->
GetBlobsGap(col - 1) / normalizing_height;
101 if ((!end_row && left_gap <
kMinGap) || left_seam->
priority() > 0.0f) {
105 tprintf(
"left_gap %g, left_seam %g %s\n", left_gap,
109 float right_gap = 0.0f;
111 right_gap = word_res->
GetBlobsGap(row) / normalizing_height;
113 if (right_gap < kMinGap || right_seam->priority() > 0.0f) {
118 tprintf(
"right_gap %g right_seam %g %s\n", right_gap,
129 if (parent_stats != NULL) {
140 tprintf(
"full_wh_ratio %g full_wh_ratio_total %g full_wh_ratio_var %g\n",
151 if (col == 0 && end_row && wh_ratio > max_char_wh_ratio) {
162 float max_char_wh_ratio) {
164 if (norm_width > max_char_wh_ratio) cost += norm_width;
166 cost += norm_width * norm_width;
168 if (norm_width+right_gap < 0.5f && !end_pos) {
169 cost += 1.0f - (norm_width + right_gap);
int GetBlobsWidth(int start_blob, int last_blob)
GenericVector< SEAM * > seam_array
static const float kMinGap
static float FixedPitchWidthCost(float norm_width, float right_gap, bool end_pos, float max_char_wh_ratio)
int GetBlobsGap(int blob_index)
float full_wh_ratio_total
GenericVector< int > blob_widths
static const float kMaxFixedPitchCharAspectRatio
bool bad_fixed_pitch_right_gap
static void ComputeStats(int col, int row, const AssociateStats *parent_stats, int parent_path_length, bool fixed_pitch, float max_char_wh_ratio, WERD_RES *word_res, bool debug, AssociateStats *stats)