chess_corners (Python)
Python-first bindings for the chess-corners detector.
The installed package is a mixed Rust/Python package:
chess_cornersis a pure-Python public API with type hints, docstrings, JSON helpers, and readable config objects.chess_corners._nativeis the private PyO3 extension module that runs the detector.
Quick start
import numpy as np
import chess_corners
img = np.zeros((128, 128), dtype=np.uint8)
cfg = chess_corners.DetectorConfig.chess_multiscale()
cfg.threshold = 60.0 # ChESS: absolute floor on the raw response (default 30)
cfg.refiner = chess_corners.ImageRefiner.saddle_point()
detector = chess_corners.Detector(cfg)
det = detector.detect(img)
print(det.xy.shape, det.xy.dtype) # (N, 2) float32
if det.angles is not None:
print(det.angles.shape) # (N, 2) float32
print(cfg)
Detector(cfg).detect(image) returns a Detections object with named
arrays:
det.xy—(N, 2)float32, subpixel corner positions (x, y) in input pixelsdet.response—(N,)float32, raw detector response at each peakdet.angles—(N, 2)float32,[axis0_angle, axis1_angle]in radians[0, π), orNonewhen orientation is disableddet.fit_std_errors—(N, 2)float32, the residual-based least-squares standard error of each axis fit in radians: a fit-quality score for ranking and gating axes (larger means a less reliable axis), not a calibrated error bound;Nonewhen orientation is disableddet.position_covariance—(N, 2, 2)float32, each corner's position covariance in px²; rows areNaNfor corners without one (every localizer reports it underUncertainty.propagated(), selected withcfg.with_uncertainty(chess_corners.Uncertainty.propagated()), orUncertainty.propagated(noise_sigma=1.2)when the image noise is known; none does under the defaultUncertainty.off()or on upscaled input);chess_corners.estimate_noise_sigma(img)returns the per-image noise estimate used when nonoise_sigmais given. The covariance includes a per-localizer floor measured on real images that usually dominates it there; weighting by it has not been shown to beat uniform weighting on real datadet.noise_sigma— the image noise σ (gray levels) behindposition_covariance: the knownnoise_sigmawhen given, otherwise the per-image estimate;Nonewhen no corner has a covariance
Rotating CCW from axis0_angle toward axis1_angle (by less than π)
traverses a dark sector of the corner; the two grid axes are not
assumed to be orthogonal, so this output correctly captures projective
warp and lens distortion.
The orientation fit is the dominant per-corner cost, and it is
optional. A pipeline that recovers board geometry from corner
positions alone can skip it with cfg.without_orientation(); in that
case det.angles and det.fit_std_errors are None.
Input requirements:
imagemust be a 2Duint8NumPy array with shape(H, W)- it must be C-contiguous
The rows are sorted deterministically by response descending, then x, then y.
Public config API
DetectorConfig is strategy-typed: detector-specific tuning lives
inside a DetectionStrategy variant. Top-level fields are
threshold, multiscale, upscale, orientation_method, and
merge_radius.
cfg = chess_corners.DetectorConfig.chess() # ChESS, no pyramid
cfg.threshold = 60.0 # plain float; ChESS = absolute response floor (default 30), Radon = fraction of per-frame max (default 0.28)
cfg.merge_radius = 3.0
# Enable the coarse-to-fine pyramid (both detectors honour this):
cfg.multiscale = chess_corners.MultiscaleConfig.pyramid(
levels=3, min_size=128, refinement_radius=3,
)
# Detector-specific knobs live inside the strategy. Nested getters
# return the live shared object, so direct attribute assignment
# propagates back to `cfg` — no rebuild needed:
cfg.strategy.chess.ring = chess_corners.ChessRing.BROAD
cfg.detection.nms_radius = 2
cfg.detection.min_cluster_size = 2
# Switch the active strategy by assigning a new one:
cfg.strategy = chess_corners.DetectionStrategy.from_radon(
chess_corners.RadonConfig()
)
For one-shot configuration, the chainable with_chess(**kwargs) /
with_radon(**kwargs) builders return a new config with only the
named fields replaced:
cfg = (
chess_corners.DetectorConfig.chess_multiscale()
.with_chess(ring=chess_corners.ChessRing.BROAD)
.with_detection(nms_radius=2, min_cluster_size=2)
.with_refiner(chess_corners.ImageRefiner.saddle_point())
)
By default each detector keeps its own localizer: the center of mass on
the ChESS response (tuned by cfg.strategy.chess.center_of_mass) or the
peak fit on the Radon response. cfg.refiner replaces it with an image
refiner, ImageRefiner.saddle_point(cfg=None), set with with_refiner(...) / cfg.refiner = ... and cleared with
without_refiner() / cfg.refiner = None. It is independent of the
detector, so it survives with_chess / with_radon.
On ChESS the refiner starts from the integer peak and drops corners it
rejects, unless with_chess(on_refiner_reject=OnRefinerReject.KEEP_CENTER_OF_MASS)
keeps them at their center-of-mass position; on Radon it starts from the peak fit and keeps the peak fit where
it does not converge. ImageRefiner.saddle_point() reports a position
covariance under Uncertainty.propagated() with either detector. Its
tuning is reachable via the payload property
(a copy; rebuild the refiner to change it):
scfg = chess_corners.SaddlePointConfig()
scfg.max_offset = 2.0
cfg.refiner = chess_corners.ImageRefiner.saddle_point(scfg)
assert cfg.refiner.kind == "saddle_point"
assert cfg.refiner.payload.max_offset == 2.0
Tagged classes:
MultiscaleConfig:MultiscaleConfig.single_scale()/MultiscaleConfig.pyramid(levels=, min_size=, refinement_radius=); readcfg.multiscale.kindand (whenpyramid)levels,min_size,refinement_radius.UpscaleConfig:UpscaleConfig.disabled()/UpscaleConfig.fixed(factor); readcfg.upscale.kindand (whenfixed)factor.ImageRefiner:saddle_point(); readcfg.refiner.kindandcfg.refiner.payload.
Enums:
ChessRing:CANONICAL,BROADPeakFitMode:PARABOLIC,GAUSSIANOrientationMethod:RING_FIT,DISK_FIT; disable the fit entirely withcfg.without_orientation()(thendet.anglesanddet.fit_std_errorsareNone)
ChessRing.BROAD uses the wider radius-10 detector sampling pattern.
Descriptors always sample at the detector ring radius.
JSON helpers and printing
Every public config object supports:
to_dict()from_dict(...)to_json()from_json(...)pretty()print()
Example:
cfg = chess_corners.DetectorConfig.chess_multiscale()
text = cfg.to_json(indent=2)
restored = chess_corners.DetectorConfig.from_json(text)
print(restored)
restored.print()
If rich is installed, .print() uses it automatically and the config objects
also expose a Rich render hook.
Canonical JSON schema
The same algorithm config schema is used by Rust, Python, docs, and the CLI:
{
"strategy": {
"chess": {
"ring": "broad",
"center_of_mass": { "radius": 2 }
}
},
"refiner": {
"saddle_point": {
"radius": 3,
"det_margin": 0.001,
"max_offset": 2.0,
"min_abs_det": 0.0001
}
},
"threshold": 60.0,
"detection": { "nms_radius": 3, "min_cluster_size": 1 },
"multiscale": {
"pyramid": {
"levels": 3,
"min_size": 96,
"refinement_radius": 4
}
},
"upscale": "disabled",
"orientation_method": "ring_fit",
"merge_radius": 2.5
}
Switch to the Radon strategy by replacing the strategy object and setting the shared detection params:
{
"strategy": {
"radon": {
"ray_radius": 4,
"image_upsample": 2,
"response_blur_radius": 1,
"peak_fit": "gaussian"
}
},
"detection": { "nms_radius": 4, "min_cluster_size": 2 }
}
Unknown keys are rejected with a clear ConfigError.
Example runners
For a complete Pillow-based example that loads the full config from JSON, run:
uv run --python .venv/bin/python python crates/chess-corners-py/examples/run_with_full_config.py \
testimages/mid.png \
config/chess_algorithm_config_example.json
For a complete Pillow-based example that defines the entire config directly in Python code and only takes the image path as an argument, run:
uv run --python .venv/bin/python python crates/chess-corners-py/examples/run_with_code_config.py \
testimages/mid.png
Both examples use Pillow only for image loading:
uv pip install --python .venv/bin/python Pillow
Metadata
Release files for chess-corners 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chess_corners-2.1.0.tar.gz | 339.7 kB | With provenance | Details for chess_corners-2.1.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chess_corners-2.1.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for chess_corners-2.1.0-cp310-abi3-win_amd64.whl |
| chess_corners-2.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for chess_corners-2.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| chess_corners-2.1.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for chess_corners-2.1.0-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 1.9 MB
Release files / chess_corners-2.1.0.tar.gz
| Download URL | chess_corners-2.1.0.tar.gz |
|---|---|
| Size | 339.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3add43dee793ea2b2c63ba5e1507fd18816545464cb5c45622e39989f0d35cc
|
|
BLAKE2b-256 checksum How to use checksums |
70b0e9295b9a71ff19f5cfb5aeeb7e3d2c73369143ed18e3db67c95a573f7b63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / chess_corners-2.1.0-cp310-abi3-win_amd64.whl
| Download URL | chess_corners-2.1.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 427.6 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2c3b2de7ca38494a716231273ef733306802d87deacbfb37b07b79ffcc07f44c
|
|
BLAKE2b-256 checksum How to use checksums |
ada186832d8bee6bf1134cb62968e4297d1f56adbda7a502fc64649ac2629321
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / chess_corners-2.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | chess_corners-2.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 583.6 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1b4bf1f4ed95d9d37340b8d361491f44fb6ef0c23c4196f8186b26b636f9d689
|
|
BLAKE2b-256 checksum How to use checksums |
aff9175b47ed9d166e8c4dff4f483d65062bd0cc3fcb7d9a1e46ac740da50595
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / chess_corners-2.1.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | chess_corners-2.1.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 533.9 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
43e9a98f371ad874a65ced82485068ebcfeec900c4510ed08c830a348d7994e7
|
|
BLAKE2b-256 checksum How to use checksums |
2621a8faee1f06fafc827b4a6d3e1835d93f246599be66ec95cdbc5530771506
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logSecurity for chess-corners 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for chess_corners-2.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.