Expand description
Ergonomic ChESS detector facade over chess-corners-core.
§Overview
This crate is the high-level entry point for the ChESS (Chess-board Extraction by Subtraction and Summation) corner detector. It exposes:
- single-scale detection on raw grayscale buffers via
find_chess_corners, - optional
image::GrayImagehelpers (seefind_chess_corners_image) when theimagefeature is enabled, - a flat user-facing
ChessConfigwith explicit modes for thresholding, ring selection, and multiscale tuning.
The detector returns subpixel CornerDescriptor values in
full-resolution image coordinates. In most applications you
construct a ChessConfig, optionally tweak its fields, and call
find_chess_corners or find_chess_corners_image.
§Quick start
§Using image (default)
The default feature set includes integration with the image
crate:
use chess_corners::{ChessConfig, RefinementMethod, find_chess_corners_image};
use image::io::Reader as ImageReader;
// Load a grayscale chessboard image.
let img = ImageReader::open("board.png")?
.decode()?
.to_luma8();
// Start from the recommended coarse-to-fine preset.
let mut cfg = ChessConfig::multiscale();
cfg.threshold_value = 0.15;
cfg.refiner.kind = RefinementMethod::Forstner;
let corners = find_chess_corners_image(&img, &cfg)?;
println!("found {} corners", corners.len());
for c in &corners {
println!(
"corner at ({:.2}, {:.2}), response {:.1}, axes [{:.2}, {:.2}] rad",
c.x, c.y, c.response, c.axes[0].angle, c.axes[1].angle,
);
}§Raw grayscale buffer
If you already have an 8-bit grayscale buffer, you can call the
detector directly without depending on image:
use chess_corners::{ChessConfig, find_chess_corners_u8};
// Single-scale convenience configuration.
let cfg = ChessConfig::single_scale();
let corners = find_chess_corners_u8(img, width, height, &cfg)?;
println!("found {} corners", corners.len());§ML refiner (feature ml-refiner)
use chess_corners::{ChessConfig, find_chess_corners_image_with_ml};
use image::GrayImage;
let img = GrayImage::new(1, 1);
let cfg = ChessConfig::single_scale();
let corners = find_chess_corners_image_with_ml(&img, &cfg).unwrap();The ML refiner runs a small ONNX model on normalized intensity
patches (uint8 / 255.0) centered at each candidate. The model
predicts [dx, dy, conf_logit], but the confidence output is
currently ignored; the offsets are applied directly. Current
benchmarks are synthetic; real-world accuracy still needs
validation. It is also slower (about 23.5 ms vs 0.6 ms for 77
corners on testimages/mid.png).
§Python bindings
The workspace includes a PyO3-based Python extension crate at
crates/chess-corners-py. It exposes chess_corners.find_chess_corners,
which accepts a 2D uint8 NumPy array and returns a float32 (N, 9) array
with columns [x, y, response, contrast, fit_rms, axis0_angle, axis0_sigma, axis1_angle, axis1_sigma]. See
crates/chess-corners-py/README.md for usage and configuration details.
For tight processing loops you can also reuse pyramid storage
explicitly via find_chess_corners_buff and the internal
pyramid module; this avoids reallocating intermediate pyramid
levels across frames. Most users should stick to
find_chess_corners / find_chess_corners_image unless they
need fine-grained control over allocations.
§Configuration
ChessConfig is intentionally flat. It exposes detector ring,
descriptor ring, threshold mode/value, NMS controls, refiner
choice, and multiscale settings directly. The detector translates
that high-level config into lower-level ChessParams and
CoarseToFineParams internally.
If you need raw response maps or more control, the most useful
low-level primitives are re-exported here:
chess_response_u8, chess_response_u8_patch, Roi,
detect_corners_from_response_with_refiner, Corner, and
corners_to_descriptors. For deeper internals (ring offsets,
SAT views, scalar reference paths) depend on chess-corners-core
directly.
§Features
image(default) – enablesfind_chess_corners_imageandimage::GrayImageintegration.rayon– parallelizes response computation and multiscale refinement over image rows. Combine withpar_pyramidto parallelize pyramid downsampling as well.ml-refiner– enables the ML-backed refiner entry points via thechess-corners-mlcrate and embedded ONNX model.simd– enables portable-SIMD accelerated inner loops for the response kernel (requires a nightly compiler). Combine withpar_pyramidto SIMD-accelerate pyramid downsampling.par_pyramid– opt-in gate for SIMD/rayonacceleration inside the pyramid builder.tracing– emits structured spans for multiscale detection, suitable for use withtracing-subscriberor JSON tracing from the CLI.cli– builds thechess-cornersbinary shipped with this crate; it is not required when using the library as a dependency.
The library API is stable across feature combinations; features only affect performance and observability, not numerical results.
The ChESS idea was proposed in the papaer Bennett, Lasenby, ChESS: A Fast and Accurate Chessboard Corner Detector, CVIU 2014
Re-exports§
pub use image::find_chess_corners_image;pub use image::find_chess_corners_image_with_refiner;
Modules§
- image
- Optional
image::GrayImagehelpers for the unified corner detector.
Structs§
- Axis
Estimate - Direction of one local grid axis with its 1σ angular uncertainty.
- Center
OfMass Config - Legacy center-of-mass refinement on the response map.
- Chess
Config - Chess
Params - Tunable parameters for the ChESS response computation and corner detection.
- Coarse
ToFine Params - Parameters controlling the coarse-to-fine multiscale detector.
- Corner
- A detected ChESS corner (subpixel).
- Corner
Descriptor - Describes a detected chessboard corner in full-resolution image coordinates.
- Forstner
Config - Förstner-style gradient-based refiner.
- Image
Buffer - Owned grayscale image buffer (u8).
- Image
View - Minimal grayscale view for refinement without taking a dependency on
image. - Pyramid
Buffers - Reusable backing storage for pyramid construction.
- Pyramid
Params - Parameters controlling pyramid generation.
- Radon
Buffers - Reusable scratch for the whole-image Radon detector. Holds the
upsampled image buffer, the four summed-area tables, the response
map, and the box-blur scratch. All buffers grow on demand and are
reused across frames — same pattern as
PyramidBuffers. - Radon
Detector Params - Configuration for the whole-image Radon detector.
- Radon
Peak Config - Configuration for
RadonPeakRefiner. - Refine
Result - Result of refining a single corner candidate.
- Refiner
Config - Response
Map - Dense response map in row-major layout.
- Roi
- Rectangular region of interest with half-open coordinate semantics
[x0, x1) × [y0, y1). - Saddle
Point Config - Quadratic saddle-point surface refiner.
- Upscale
Buffers - Reusable scratch buffer for the upscaling stage.
- Upscale
Config - Upscaling configuration exposed through
crate::ChessConfig.
Enums§
- Chess
Error - Errors returned by detection and heatmap entry points.
- Descriptor
Mode - Detector
Mode - Detector kernel selection.
CanonicalandBroadare the two ChESS variants (radius-5 and radius-10 rings);Radonpicks the whole-image Duda-Frese detector viachess_corners_core::radon_response_u8/chess_corners_core::detect_corners_from_radon. The Radon detector is useful under heavy blur, low contrast, or cells smaller than the ChESS ring support. - Peak
FitMode - Subpixel peak-fitting mode.
- Refine
Status - Status of a refinement attempt.
- Refinement
Method - Refiner
- Runtime refiner with reusable scratch buffers.
- Refiner
Kind - User-facing enum selecting a refinement backend.
- Threshold
Mode - Upscale
Error - Errors returned by upscaling setup or execution.
- Upscale
Mode - Upscaling mode, encoded into JSON as
"disabled"or"fixed".
Traits§
- Corner
Refiner - Trait implemented by pluggable refinement backends.
Functions§
- chess_
response_ u8 - Compute the dense ChESS response for an 8-bit grayscale image.
- chess_
response_ u8_ patch - Compute the ChESS response only inside a rectangular ROI of the image.
- corners_
to_ descriptors - Convert raw corner candidates into full descriptors by sampling the source image.
- detect_
corners_ from_ response - Core detector: run NMS + refinement on an existing response map.
- detect_
corners_ from_ response_ with_ refiner - Detector variant that accepts a user-provided refiner implementation.
- find_
chess_ corners - Detect corners from a base-level grayscale view, allocating pyramid storage internally.
- find_
chess_ corners_ buff - Detect corners using a caller-provided pyramid buffer.
- find_
chess_ corners_ buff_ with_ refiner - Variant of
find_chess_corners_buffthat accepts an explicit refiner selection. - find_
chess_ corners_ u8 - Detect chessboard corners from a raw grayscale image buffer.
- find_
chess_ corners_ u8_ with_ refiner - Detect corners from a raw grayscale buffer with an explicit refiner choice.
- find_
chess_ corners_ with_ refiner - Single-call helper that lets callers pick the refiner.
- radon_
heatmap_ image - Compute the Radon response heatmap from an
image::GrayImage. - radon_
heatmap_ u8 - Compute the whole-image Radon response heatmap from a raw grayscale buffer.
- rescale_
descriptors_ to_ input - Rescale corner positions from an upscaled image back to the original input-image pixel frame.
- upscale_
bilinear_ u8 - Bilinear upscaling by an integer factor into the provided buffer.