feat(scanner): support variable Ribbon geometries#36
Conversation
📝 WalkthroughWalkthroughThe PR refactors glyphnet-scanner's ribbon decoding to support variable geometry. It introduces a ChangesVariable Geometry Ribbon Decoding
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Burst reliability (loss sweep)✅ PR gate status: PASS
|
Scanner perf (ribbon + matrix fixtures)✅ PR gate status: PASS
Matrix subset
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/glyphnet-scanner/src/decode_paths.rs`:
- Around line 234-249: The fractional_ribbon_geometry_candidates function
currently always returns DEFAULT_PRINT_RIBBON (96x36); instead, compute
candidate RibbonGeometry values from the observed image_width and image_height
by deriving a scale = image_width / DEFAULT_PRINT_RIBBON.total_width_modules()
and/or using both scale_x and scale_y (via total_width_modules() and
total_height_modules()) to compute symbol_width and symbol_height, round or
floor/ceil to nearby integer module sizes, and produce a Vec of plausible
RibbonGeometry variants around that scale (e.g., exact rounded, +/-1 module
sizes, and swapped scale fits) rather than the hard-coded DEFAULT_PRINT_RIBBON;
update fractional_ribbon_geometry_candidates to return those computed candidates
(referencing DEFAULT_PRINT_RIBBON, fractional_ribbon_geometry_candidates,
total_width_modules(), total_height_modules()) so the fractional path can
explore non-reference ribbon sizes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a3ddf23a-d87a-44d2-bfcb-d689fd011796
📒 Files selected for processing (3)
.gitignorecrates/glyphnet-scanner/src/decode_paths.rscrates/glyphnet-scanner/src/lib.rs
| fn fractional_ribbon_geometry_candidates( | ||
| image_width: u32, | ||
| image_height: u32, | ||
| ) -> Vec<RibbonGeometry> { | ||
| const DEFAULT_PRINT_RIBBON: RibbonGeometry = RibbonGeometry { | ||
| symbol_width: 96, | ||
| symbol_height: 36, | ||
| }; | ||
|
|
||
| let scale_x = image_width as f32 / DEFAULT_PRINT_RIBBON.total_width_modules() as f32; | ||
| let scale_y = image_height as f32 / DEFAULT_PRINT_RIBBON.total_height_modules() as f32; | ||
| if scale_x >= 1.0 && scale_y >= 1.0 && (0.6..=1.7).contains(&(scale_x / scale_y)) { | ||
| vec![DEFAULT_PRINT_RIBBON] | ||
| } else { | ||
| Vec::new() | ||
| } |
There was a problem hiding this comment.
Fractional decoding is still pinned to the reference geometry.
fractional_ribbon_geometry_candidates() only ever returns DEFAULT_PRINT_RIBBON, so the fractional path never explores the non-reference ribbon sizes this PR is introducing. That means any variable-geometry ribbon that needs the fractional fallback will still end up at AutoDetectFailed even though the exact path was generalized.
Please generate candidate RibbonGeometry values from the observed image dimensions instead of hard-coding 96x36 here.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/glyphnet-scanner/src/decode_paths.rs` around lines 234 - 249, The
fractional_ribbon_geometry_candidates function currently always returns
DEFAULT_PRINT_RIBBON (96x36); instead, compute candidate RibbonGeometry values
from the observed image_width and image_height by deriving a scale = image_width
/ DEFAULT_PRINT_RIBBON.total_width_modules() and/or using both scale_x and
scale_y (via total_width_modules() and total_height_modules()) to compute
symbol_width and symbol_height, round or floor/ceil to nearby integer module
sizes, and produce a Vec of plausible RibbonGeometry variants around that scale
(e.g., exact rounded, +/-1 module sizes, and swapped scale fits) rather than the
hard-coded DEFAULT_PRINT_RIBBON; update fractional_ribbon_geometry_candidates to
return those computed candidates (referencing DEFAULT_PRINT_RIBBON,
fractional_ribbon_geometry_candidates, total_width_modules(),
total_height_modules()) so the fractional path can explore non-reference ribbon
sizes.
Summary by CodeRabbit
Refactor
Tests
Chores