34 int parent_path_length,
bool fixed_pitch,
float max_char_wh_ratio,
43 tprintf(
"AssociateUtils::ComputeStats() for col=%d, row=%d%s\n", col, row,
44 fixed_pitch ?
" (fixed pitch)" :
"");
49 if (fixed_pitch && blob_row !=
nullptr) {
60 tprintf(
"normalizing height = %g (scale %g xheight %g ascenders %g)\n", normalizing_height,
64 float wh_ratio = word_res->
GetBlobsWidth(col, row) / normalizing_height;
65 if (wh_ratio > max_char_wh_ratio) {
72 int negative_gap_sum = 0;
73 for (
int c = col; c < row; ++c) {
75 (gap > 0) ? stats->
gap_sum += gap : negative_gap_sum += gap;
78 stats->
gap_sum = negative_gap_sum;
81 tprintf(
"wh_ratio=%g (max_char_wh_ratio=%g) gap_sum=%d %s\n", wh_ratio, max_char_wh_ratio,
92 float left_gap = word_res->
GetBlobsGap(col - 1) / normalizing_height;
98 tprintf(
"left_gap %g, left_seam %g %s\n", left_gap, left_seam->
priority(),
102 float right_gap = 0.0f;
104 right_gap = word_res->
GetBlobsGap(row) / normalizing_height;
106 if (right_gap < kMinGap || right_seam->priority() > 0.0f) {
113 tprintf(
"right_gap %g right_seam %g %s\n", right_gap, right_seam->
priority(),
124 if (parent_stats !=
nullptr) {
133 tprintf(
"full_wh_ratio %g full_wh_ratio_total %g full_wh_ratio_var %g\n",
142 if (col == 0 && end_row && wh_ratio > max_char_wh_ratio) {
153 float max_char_wh_ratio) {
155 if (norm_width > max_char_wh_ratio) {
159 cost += norm_width * norm_width;
162 if (norm_width + right_gap < 0.5f && !end_pos) {
163 cost += 1.0f - (norm_width + right_gap);
void tprintf(const char *format,...)
int GetBlobsGap(unsigned blob_index) const
std::vector< int > blob_widths
int GetBlobsWidth(int start_blob, int last_blob) const
std::vector< SEAM * > seam_array
float full_wh_ratio_total
bool bad_fixed_pitch_right_gap
static const float kMaxFixedPitchCharAspectRatio
static const float kMinGap
static float FixedPitchWidthCost(float norm_width, float right_gap, bool end_pos, float max_char_wh_ratio)
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)