@@ -31,7 +31,7 @@ static int debug_counter = 0;
3131// Full OCR preprocessing pipeline for GBA pixel fonts.
3232//
3333// GBA fonts are seven-segment-like with 1-pixel gaps between segments.
34- // Pipeline: blur at native → smooth upscale → BW → smooth BW → re-BW → pad
34+ // Pipeline: blur at native -> smooth upscale -> BW -> smooth BW -> re-BW -> pad
3535//
3636// The native blur connects gaps. Post-BW padding provides margins.
3737static ImageRGB32 preprocess_for_ocr (
@@ -52,8 +52,8 @@ static ImageRGB32 preprocess_for_ocr(
5252
5353 cv::Mat src = image.to_opencv_Mat ();
5454
55- // Step 1: Gaussian blur at NATIVE resolution with 5×5 kernel.
56- // The 5×5 kernel reaches 2 pixels away (vs 1px for 3×3 ), bridging
55+ // Step 1: Gaussian blur at NATIVE resolution with 5x5 kernel.
56+ // The 5x5 kernel reaches 2 pixels away (vs 1px for 3x3 ), bridging
5757 // wider gaps in the seven-segment font. Two passes for heavy smoothing.
5858 cv::Mat blurred_native;
5959 src.copyTo (blurred_native);
@@ -73,7 +73,7 @@ static ImageRGB32 preprocess_for_ocr(
7373 blurred_native_img.save (prefix + " _1_blurred_native.png" );
7474 }
7575
76- // Step 2: Smooth upscale 4× with bilinear interpolation.
76+ // Step 2: Smooth upscale 4x with bilinear interpolation.
7777 int scale_factor = 4 ;
7878 int new_w = static_cast <int >(image.width ()) * scale_factor;
7979 int new_h = static_cast <int >(image.height ()) * scale_factor;
@@ -97,7 +97,7 @@ static ImageRGB32 preprocess_for_ocr(
9797 bw.save (prefix + " _3_bw.png" );
9898 }
9999
100- // Step 4: Post-BW smoothing → re-threshold.
100+ // Step 4: Post-BW smoothing -> re-threshold.
101101 // The BW image has angular seven-segment shapes. GaussianBlur on the
102102 // binary image creates gray anti-aliased edges. Re-thresholding at 128
103103 // rounds the corners into natural smooth digit shapes that Tesseract
@@ -109,7 +109,7 @@ static ImageRGB32 preprocess_for_ocr(
109109 // Re-threshold: convert smoothed back to ImageRGB32 and BW threshold.
110110 // After blur on BW: text areas are dark gray (~0-64), bg areas are
111111 // light gray (~192-255), edge zones are mid-gray (~64-192).
112- // Threshold at [0..128] captures text + expanded edges → BLACK.
112+ // Threshold at [0..128] captures text + expanded edges -> BLACK.
113113 ImageRGB32 smoothed_img (smoothed.cols , smoothed.rows );
114114 smoothed.copyTo (smoothed_img.to_opencv_Mat ());
115115 ImageRGB32 smooth_bw = to_blackwhite_rgb32_range (
@@ -211,8 +211,8 @@ void StatsReader::read_page1(
211211
212212 if (!GlobalSettings::instance ().USE_PADDLE_OCR ) {
213213 // The level uses white text with dark shadow on a lilac background.
214- // The digit reader's binarizer captures dark pixels (≤ 190 on all channels)
215- // but NOT the white text (all channels 255 → excluded). This leaves the
214+ // The digit reader's binarizer captures dark pixels (<= 190 on all channels)
215+ // but NOT the white text (all channels 255 -> excluded). This leaves the
216216 // shadow outline fragmented into many small disconnected blobs.
217217 // Preprocess: convert bright-white text pixels to black so the binarizer
218218 // merges text + shadow into one solid connected blob per digit.
@@ -222,7 +222,7 @@ void StatsReader::read_page1(
222222 if (save_debug_images) {
223223 preprocessed.save (" DebugDumps/ocr_level_preprocessed.png" );
224224 }
225- // Trim left 7% to exclude the "L" glyph blob (always at x≈ 0).
225+ // Trim left 7% to exclude the "L" glyph blob (always at x~ 0).
226226 // The actual level digits start at ~13%+ of the box width.
227227 size_t lv_skip = preprocessed.width () * 7 / 100 ;
228228 ImagePixelBox digits_bbox (
@@ -245,27 +245,27 @@ void StatsReader::read_page1(
245245 }
246246
247247 // Read Nature (black text on white/beige).
248- // Pipeline: BW → invert → morph close → invert → upscale → smooth → pad.
248+ // Pipeline: BW -> invert -> morph close -> invert -> upscale -> smooth -> pad.
249249 // Morph close on the inverted image (text=white) bridges gaps in text
250- // regions by growing white→ eroding back. Works per-channel on CV_8UC4.
250+ // regions by growing white-> eroding back. Works per-channel on CV_8UC4.
251251 const static Pokemon::NatureReader reader (" Pokemon/NatureCheckerOCR.json" );
252252 ImageViewRGB32 nature_raw = extract_box_reference (game_screen, m_box_nature);
253253 if (save_debug_images) {
254254 nature_raw.save (" DebugDumps/ocr_nature_0_raw.png" );
255255 }
256256
257- // Step 1: BW at native resolution. Dark text [0..150] → black.
257+ // Step 1: BW at native resolution. Dark text [0..150] -> black.
258258 ImageRGB32 nature_bw = to_blackwhite_rgb32_range (
259259 nature_raw, true ,
260260 combine_rgb (0 , 0 , 0 ), combine_rgb (150 , 150 , 150 ));
261261 if (save_debug_images) {
262262 nature_bw.save (" DebugDumps/ocr_nature_1_bw.png" );
263263 }
264264
265- // Step 2: Invert → MORPH_CLOSE → Invert to bridge gaps.
265+ // Step 2: Invert -> MORPH_CLOSE -> Invert to bridge gaps.
266266 // On the inverted image, text is bright (255) and bg is dark (0).
267267 // MORPH_CLOSE (dilate then erode) fills small dark holes within
268- // the bright text regions — exactly the 1px gaps we need to bridge.
268+ // the bright text regions - exactly the 1px gaps we need to bridge.
269269 // A 3x3 kernel bridges 1px gaps. Two iterations bridges 2px gaps.
270270 {
271271 cv::Mat bw_mat = nature_bw.to_opencv_Mat ();
@@ -396,15 +396,15 @@ void StatsReader::read_page2(
396396 }
397397
398398 // PaddleOCR path (original): preprocess then per-digit waterfill OCR.
399- // Dark text [0..190] → black. Threshold at 190 captures the
399+ // Dark text [0..190] -> black. Threshold at 190 captures the
400400 // blurred gap pixels between segments, making bridges thicker.
401401 // Not higher than 190 to avoid capturing yellow bg edge noise.
402402 ImageRGB32 ocr_ready = preprocess_for_ocr (
403403 stat_region, name, 7 , 2 , true ,
404404 combine_rgb (0 , 0 , 0 ), combine_rgb (190 , 190 , 190 )
405405 );
406406
407- // Waterfill isolates each digit → per-char SINGLE_CHAR OCR.
407+ // Waterfill isolates each digit -> per-char SINGLE_CHAR OCR.
408408 return OCR::read_number_waterfill (
409409 logger, ocr_ready, 0xff000000 ,
410410 0xff808080
0 commit comments