chess-corners
Ergonomic chessboard corner detector on top of chess-corners-core.
This crate is the public Rust API:
- strategy-typed
DetectorConfig(DetectionStrategy::Chess(ChessConfig)/DetectionStrategy::Radon(RadonConfig)) with a unifiedThresholdenum and per-detector refiner selection (ChessRefiner,RadonRefiner) - top-level
MultiscaleConfig(SingleScale | Pyramid { ... }) andUpscaleConfig(Disabled | Fixed(factor)), honoured by both detectors symmetrically - single-scale and coarse-to-fine multiscale detection through a single
Detectorstruct that reuses pyramid and scratch buffers across frames - optional
image::GrayImagehelpers - optional CLI binary and ML-backed refinement pipeline
chess-corners-core and box-image-pyramid remain available as
lower-level sharp tools, but chess-corners is the intended
compatibility boundary.
Quick start
use ;
use ImageReader;
Detector owns the pyramid and upscale scratch buffers, so calling
detector.detect(&img) repeatedly on successive frames does not
re-allocate.
Presets
| Preset | Detector | Scale |
|---|---|---|
DetectorConfig::chess() |
ChESS | Single-scale |
DetectorConfig::chess_multiscale() |
ChESS | 3-level pyramid |
DetectorConfig::radon() |
Radon | Single-scale |
DetectorConfig::radon_multiscale() |
Radon | 3-level pyramid |
single_scale() and multiscale() are deprecated aliases for chess() and
chess_multiscale() respectively, and will be removed in 0.12.0.
Public config shape
DetectorConfig groups detector-specific tuning under a typed
DetectionStrategy enum and shares cross-cutting fields at the top
level:
use ;
let cfg = chess
.with_threshold
.with_merge_radius
.with_multiscale
.with_upscale
.with_chess;
// Or switch to the Radon strategy:
let cfg = cfg.with_radon;
Three guarantees follow from this shape:
- One place per knob.
cfg.strategy.chess.ring = ChessRing::Broadis the only way to request the wider ChESS ring. - Per-detector refiners.
ChessRefinerlists only refiners that operate on ChESS output;RadonRefinerlists only those that operate on Radon output. - Symmetric encoding.
Threshold,MultiscaleConfig,UpscaleConfig, and both refiner enums use the same enum-with- payload shape, so the JSON and binding surface stays uniform.
Descriptor output
Each detection is a CornerDescriptor with:
x,y— subpixel position.response— raw unnormalized detector response (the ChESS paper's score for ChESS,(max α S_α − min α S_α)²for Radon).contrast— fitted bright/dark amplitude|A|in gray levels.fit_rms— RMS residual of the two-axis fit in gray levels.axes[0],axes[1]— the two local grid axes with per-axis 1σ angular uncertainty from the Gauss-Newton covariance (σθᵢ = √((SSR / 12) · (JᵀJ)⁻¹[i,i])). Axes are not assumed orthogonal;axes[0].angle ∈ [0, π)andaxes[1].angle ∈ (axes[0].angle, axes[0].angle + π), with the CCW arc between them spanning a dark sector.
Refiner configuration
ChessRefiner and RadonRefiner are tagged enums; each variant
carries its tuning struct as a payload, so switching kinds cannot
leave a stale per-refiner config behind:
use ;
let cfg = chess.with_chess;
The Radon equivalent uses RadonRefiner::RadonPeak(_) or
RadonRefiner::CenterOfMass(_). A ChessRefiner::RadonPeak (or
vice versa) mismatch is unrepresentable.
CLI config shape
The CLI uses the same DetectorConfig schema, combined with
application fields such as image, output_json, output_png,
log_level, and ml.
See:
config/chess_algorithm_config_example.jsonfor the pureDetectorConfigshape (round-trips through the Rust and Python APIs).config/chess_cli_config_example.jsonfor a complete CLI runner input (algorithm config + envelope).
ML refiner
Enable the ml-refiner feature, then pick the Ml variant on the
ChESS strategy's refiner:
#
#
The ML path is slower than the classic refiners in the shipped benchmark and falls back to the classic CenterOfMass refiner at coarse pyramid levels.
Examples
- Single-scale:
cargo run -p chess-corners --example single_scale_image -- testimages/mid.png - Multiscale:
cargo run -p chess-corners --example multiscale_image -- testimages/large.png
Feature flags
image(default):image::GrayImageintegrationrayon: parallel response/refinementsimd: portable-SIMD acceleration in the core response pathpar_pyramid: SIMD/rayonin pyramid constructiontracing: structured spansml-refiner: ONNX-backed ML refinementcli: build thechess-cornersbinary