1064 {
1065 LocalCorrelation pitch_height_stats;
1066
1067 num_tall_rows_ = 0;
1068 num_bad_rows_ = 0;
1069 pitch_height_stats.Clear();
1070 for (auto &row : rows_) {
1071 row.EstimatePitch(pass1);
1072 if (row.good_pitches()) {
1073 pitch_height_stats.Add(row.height() + row.gap(), row.pitch(), row.good_pitches());
1074 if (row.height_pitch_ratio() > 1.1) {
1075 num_tall_rows_++;
1076 }
1077 } else {
1078 num_bad_rows_++;
1079 }
1080 }
1081
1082 pitch_height_stats.Finish();
1083 for (auto &row : rows_) {
1084 if (row.good_pitches() >= 5) {
1085
1086
1087 row.set_estimated_pitch(row.pitch());
1088 } else if (row.num_chars() > 1) {
1089 float estimated_pitch = pitch_height_stats.EstimateYFor(row.height() + row.gap(), 0.1f);
1090
1091
1092
1093
1094 if (estimated_pitch > row.pitch() || row.pitch() > row.height() * 2.0) {
1095 row.set_estimated_pitch(estimated_pitch);
1096 } else {
1097 row.set_estimated_pitch(row.pitch());
1098 }
1099 }
1100 }
1101}