Python bindings for the fast ChESS chessboard corner detector (Rust backend)
Project description
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.ChessConfig.multiscale()
cfg.threshold_value = 0.15
cfg.refiner.kind = chess_corners.RefinementMethod.FORSTNER
corners = chess_corners.find_chess_corners(img, cfg)
print(corners.shape, corners.dtype)
print(cfg)
find_chess_corners(image, cfg=None) returns a NumPy float32 array of shape
(N, 9) with columns:
x— subpixel corner x in input pixelsy— subpixel corner y in input pixelsresponse— raw ChESS response at the detected peakcontrast— amplitude of the fitted bright/dark structurefit_rms— RMS residual of the two-axis intensity fit (gray levels)axis0_angle— angle of the first local grid axis, radians in[0, π)axis0_sigma— 1σ uncertainty ofaxis0_angle, radiansaxis1_angle— angle of the second local grid axis, radians in(axis0_angle, axis0_angle + π)axis1_sigma— 1σ uncertainty ofaxis1_angle, radians
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.
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
The public config shape is intentionally flat. There is no params section and
no nested pyramid object.
cfg = chess_corners.ChessConfig()
cfg.detector_mode = chess_corners.DetectorMode.BROAD
cfg.descriptor_mode = chess_corners.DescriptorMode.FOLLOW_DETECTOR
cfg.threshold_mode = chess_corners.ThresholdMode.RELATIVE
cfg.threshold_value = 0.2
cfg.nms_radius = 2
cfg.min_cluster_size = 2
cfg.pyramid_levels = 3
cfg.pyramid_min_size = 128
cfg.refinement_radius = 3
cfg.merge_radius = 3.0
All nested objects are default-initialized, so you can always do:
cfg = chess_corners.ChessConfig()
cfg.refiner.kind = chess_corners.RefinementMethod.FORSTNER
cfg.refiner.forstner.max_offset = 2.0
Supported enums:
DetectorMode:canonical,broadDescriptorMode:follow_detector,canonical,broadThresholdMode:relative,absoluteRefinementMethod:center_of_mass,forstner,saddle_point
broad uses the wider, blur-tolerant detector sampling pattern. Leave
descriptor_mode at follow_detector unless you have a reason to override
descriptor or orientation sampling separately.
Refiner configuration
cfg.refiner always contains every leaf config:
cfg.refiner.center_of_masscfg.refiner.forstnercfg.refiner.saddle_point
Only cfg.refiner.kind selects which one is active.
cfg = chess_corners.ChessConfig()
cfg.refiner.kind = chess_corners.RefinementMethod.SADDLE_POINT
cfg.refiner.saddle_point.radius = 3
cfg.refiner.saddle_point.max_offset = 2.0
JSON helpers and printing
Every public config object supports:
to_dict()from_dict(...)to_json()from_json(...)pretty()print()
Example:
cfg = chess_corners.ChessConfig.multiscale()
text = cfg.to_json(indent=2)
restored = chess_corners.ChessConfig.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:
{
"detector_mode": "broad",
"descriptor_mode": "canonical",
"threshold_mode": "absolute",
"threshold_value": 0.5,
"nms_radius": 3,
"min_cluster_size": 1,
"refiner": {
"kind": "forstner",
"center_of_mass": {
"radius": 2
},
"forstner": {
"radius": 3,
"min_trace": 20.0,
"min_det": 0.001,
"max_condition_number": 60.0,
"max_offset": 2.0
},
"saddle_point": {
"radius": 3,
"det_margin": 0.002,
"max_offset": 1.75,
"min_abs_det": 0.0002
}
},
"pyramid_levels": 3,
"pyramid_min_size": 96,
"refinement_radius": 4,
"merge_radius": 2.5
}
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
ML refiner
If the bindings are built with the ml-refiner feature, the package also exports:
corners = chess_corners.find_chess_corners_with_ml(img, cfg)
That toggles the separate ML-backed refinement path. It does not change the
canonical ChessConfig schema.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chess_corners-0.8.0.tar.gz.
File metadata
- Download URL: chess_corners-0.8.0.tar.gz
- Upload date:
- Size: 882.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05a7b8975aa47d17d567083fb931a5994b5c0893131214e76d8bd2aa0c6128d1
|
|
| MD5 |
afbecb9e4857c1d223077abd9320cfd4
|
|
| BLAKE2b-256 |
93bb5ef077695a05956ac0bf62073645094679ee397867197d0650cbae29d201
|
Provenance
The following attestation bundles were made for chess_corners-0.8.0.tar.gz:
Publisher:
release-pypi.yml on VitalyVorobyev/chess-corners-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chess_corners-0.8.0.tar.gz -
Subject digest:
05a7b8975aa47d17d567083fb931a5994b5c0893131214e76d8bd2aa0c6128d1 - Sigstore transparency entry: 1397573513
- Sigstore integration time:
-
Permalink:
VitalyVorobyev/chess-corners-rs@95d4e5f0d7458a8841ebb45fb3539b9e2ce40e65 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/VitalyVorobyev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@95d4e5f0d7458a8841ebb45fb3539b9e2ce40e65 -
Trigger Event:
push
-
Statement type:
File details
Details for the file chess_corners-0.8.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: chess_corners-0.8.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 5.9 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbe832a3379d4e79c555a2da5203c24d551f0b3eb562d34d0bd34814d0d1a6d0
|
|
| MD5 |
e615769a7e99c57a7077283421aefa55
|
|
| BLAKE2b-256 |
59dc4512cc8a6680bbe107acf34e258bf104f1339267f8578619d55cc3303962
|
Provenance
The following attestation bundles were made for chess_corners-0.8.0-cp310-abi3-win_amd64.whl:
Publisher:
release-pypi.yml on VitalyVorobyev/chess-corners-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chess_corners-0.8.0-cp310-abi3-win_amd64.whl -
Subject digest:
fbe832a3379d4e79c555a2da5203c24d551f0b3eb562d34d0bd34814d0d1a6d0 - Sigstore transparency entry: 1397573524
- Sigstore integration time:
-
Permalink:
VitalyVorobyev/chess-corners-rs@95d4e5f0d7458a8841ebb45fb3539b9e2ce40e65 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/VitalyVorobyev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@95d4e5f0d7458a8841ebb45fb3539b9e2ce40e65 -
Trigger Event:
push
-
Statement type:
File details
Details for the file chess_corners-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: chess_corners-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 6.9 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f2c205227ac489f95192e3d9465954c73df90979bb50a78c7ad6df6d5fde405
|
|
| MD5 |
55fff3a17018e8f883164ae35bf261a4
|
|
| BLAKE2b-256 |
bda804f33f65317cb9ac5f1c08966b13e2f332b02406243934e67afb985d97be
|
Provenance
The following attestation bundles were made for chess_corners-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-pypi.yml on VitalyVorobyev/chess-corners-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chess_corners-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
1f2c205227ac489f95192e3d9465954c73df90979bb50a78c7ad6df6d5fde405 - Sigstore transparency entry: 1397573535
- Sigstore integration time:
-
Permalink:
VitalyVorobyev/chess-corners-rs@95d4e5f0d7458a8841ebb45fb3539b9e2ce40e65 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/VitalyVorobyev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@95d4e5f0d7458a8841ebb45fb3539b9e2ce40e65 -
Trigger Event:
push
-
Statement type:
File details
Details for the file chess_corners-0.8.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: chess_corners-0.8.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19edbe584c0f9620605e58b1ed4785a9f62ad378371a9ae3da56df80267f9302
|
|
| MD5 |
52de361d76ede91569c97190f193ff6c
|
|
| BLAKE2b-256 |
c2b75dabd852eef181fc4cead187fdddbd7d4d940eaae3f9af039318a5e1048d
|
Provenance
The following attestation bundles were made for chess_corners-0.8.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
release-pypi.yml on VitalyVorobyev/chess-corners-rs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chess_corners-0.8.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
19edbe584c0f9620605e58b1ed4785a9f62ad378371a9ae3da56df80267f9302 - Sigstore transparency entry: 1397573546
- Sigstore integration time:
-
Permalink:
VitalyVorobyev/chess-corners-rs@95d4e5f0d7458a8841ebb45fb3539b9e2ce40e65 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/VitalyVorobyev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@95d4e5f0d7458a8841ebb45fb3539b9e2ce40e65 -
Trigger Event:
push
-
Statement type: