Expand description
§ringgrid
Pure-Rust detector for dense coded ring calibration targets on a hex lattice.
ringgrid detects ring markers in grayscale images, decodes their 16-sector binary IDs from the shipped baseline 893-codeword profile (with an opt-in extended profile available for advanced use), fits subpixel ellipses via Fitzgibbon’s direct method with RANSAC, and estimates a board-to-image homography. No OpenCV dependency — all image processing is in Rust.
§Detection Modes
- Simple —
Detector::detect: single-pass detection in image coordinates. Use when the camera has negligible distortion. - External mapper —
Detector::detect_with_mapper: two-pass pipeline with aPixelMapper(e.g.CameraModel) for distortion-aware detection. - Self-undistort —
Detector::detectwithSelfUndistortConfig::enableset totrue: estimates a 1-parameter division-model distortion from detected markers and optionally re-runs detection with the estimated correction.
§Quick Start
use ringgrid::{Detector, TargetLayout};
use std::path::Path;
let target = TargetLayout::from_json_file(Path::new("target.json")).unwrap();
let image = image::open("photo.png").unwrap().to_luma8();
let detector = Detector::new(target);
let result = detector.detect(&image).unwrap();
for marker in &result.detected_markers {
if let Some(id) = marker.id {
println!("Marker {id} at ({:.1}, {:.1})", marker.center[0], marker.center[1]);
}
}Targets can also be built in code (no files needed):
use ringgrid::{Detector, TargetLayout};
let target = TargetLayout::default_hex();
let detector = Detector::new(target);
// An empty image yields a valid result with no detections.
let image = image::GrayImage::new(64, 48);
let result = detector.detect(&image).unwrap();
assert!(result.detected_markers.is_empty());§Coordinate Frames
Marker centers (DetectedMarker::center) are always in image-pixel
coordinates, regardless of mapper usage. When a PixelMapper is active,
DetectedMarker::center_mapped provides the working-frame (undistorted)
coordinates, and the homography maps board coordinates to the working frame.
DetectedMarker::board_xy_mm provides board-space marker coordinates in
millimeters when a valid decoded ID is available on the active board.
See DetectionResult::center_frame and DetectionResult::homography_frame
for the frame metadata on each result.
Modules§
- codebook
- Inspection helpers for the embedded 16-sector codebook profiles.
- diagnostics
- Opt-in diagnostics channel returned by
Detector::detect_with_diagnostics: per-marker fit and decode metrics, homography RANSAC statistics, and pipeline stage timings.
Structs§
- Advanced
Detect Config - Advanced per-stage tuning parameters for the detection pipeline.
- Camera
Intrinsics - Pinhole camera intrinsics.
- Camera
Model - Complete camera model (intrinsics + radial-tangential distortion).
- Coded
Ring Spec - Parameters of the 16-sector coded ring style.
- Completion
Config - Configuration for homography-guided completion: attempt local fits for missing IDs at H-projected board locations.
- Decode
Config - Configuration for sector decoding.
- Detect
Config - Top-level detection configuration.
- Detected
Marker - A detected marker: refined geometry plus the decoded ID.
- Detection
Result - Detection result for a single image.
- Detector
- Primary detection interface.
- Division
Model - Single-parameter division distortion model.
- Edge
Sample Config - Configuration for radial edge sampling.
- Ellipse
- Geometric ellipse parameters fitted to a ring marker boundary.
- HexGeometry
- Hex-lattice geometry: axial rows alternating between long and short rows.
- IdCorrection
Config - Structural ID verification and correction using hex neighborhood consensus.
- Inner
AsOuter Recovery Config - Configuration for automatic recovery of markers where the inner edge was incorrectly fitted as the outer ellipse.
- Inner
FitConfig - Configuration for robust inner ellipse fitting from outer-fit hints.
- Marker
Scale Prior - Scale prior for marker diameter in detector working pixels.
- Marker
Spec Config - Marker spec in outer-normalized radius units.
- Origin
Fiducials - Filled circular dots that define the target’s origin and orientation.
- Outer
Estimation Config - Configuration for outer-radius estimation around a center prior.
- Outer
FitConfig - Configuration for robust outer ellipse fitting from sampled edge points.
- PngTarget
Options - PNG target-generation options.
- Projective
Center Config - Projective-only unbiased center recovery from inner/outer conics.
- Proposal
- A proposed ellipse center with its vote score.
- Proposal
Config - Configuration for ellipse center detection via gradient-based radial symmetry voting.
- Proposal
Result - Proposals together with the vote heatmap for visualization or custom processing.
- Radial
Tangential Distortion - Brown-Conrady radial-tangential distortion coefficients.
- Ransac
Config - Configuration for RANSAC fitting (ellipse and homography).
- Rect
Geometry - Rectangular (square-lattice) geometry:
rows × colscells at uniform pitch. - Ring
Geometry - Ring radii shared by every marker on the target, in millimeters.
- Scale
Tier - One scale band for multi-scale adaptive detection.
- Scale
Tiers - An ordered set of scale tiers for multi-scale adaptive detection.
- Seed
Proposal Config - Seed-injection controls for proposal generation.
- Self
Undistort Config - Configuration for self-undistort estimation.
- Self
Undistort Result - Result of self-undistort estimation.
- SvgTarget
Options - SVG target-generation options.
- Target
Cell - One marker cell of a target: lattice coordinate, board position, and (for coded targets) the assigned codebook ID.
- Target
Layout - Compositional target layout: lattice × ring geometry × coding × fiducials.
- Undistort
Config - Distortion inversion settings used by iterative undistortion.
Enums§
- Angular
Aggregator - Aggregation method across theta samples.
- Board
Frame - Reference frame of grid-labeled outputs (
grid_coord,board_xy_mm, and the homography’s source plane). - Circle
Refinement Method - Center-correction strategy used after local fits are accepted.
- Codebook
Profile - Explicit embedded codebook profile selector.
- Detect
Error - Detection-time failures reported by
Detectormethods. - Detection
Frame - Coordinate frame used by serialized detection outputs.
- Grad
Polarity - Expected polarity of the radial intensity derivative
dI/drat an edge. - Lattice
Geometry - Lattice arrangement of marker cells.
- Marker
Coding - Marker coding style: how (and whether) markers encode their identity.
- Proposal
Downscale - Controls optional image downscaling before proposal generation.
- Target
Generation Error - Target-generation failures.
- Target
Load Error - Load-time failures for target layout JSON.
- Target
Validation Error - Validation failures for a target layout specification.
Traits§
- Pixel
Mapper - Mapping between raw image pixels and detector working-frame pixels.
Functions§
- find_
ellipse_ centers - Detect candidate ellipse centers via radial symmetry voting.
- find_
ellipse_ centers_ with_ heatmap - Detect candidate ellipse centers and return the vote heatmap.
- propose_
with_ heatmap_ and_ marker_ scale - Generate pass-1 proposals with heatmap using target geometry and an explicit marker-scale prior.
- propose_
with_ marker_ scale - Generate pass-1 center proposals using target geometry and an explicit marker-scale prior.