Audit OpenCV checkerboard calibration datasets, detect weak or duplicate views, visualize image-plane coverage, calibrate the camera, and generate an explainable offline report.
Project description
OpenCV Calibration Audit
Audit OpenCV checkerboard calibration datasets, reject weak or duplicate views, visualize image-plane coverage, calibrate a monocular pinhole camera, and create an explainable offline report.
Unlike a short cv2.calibrateCamera() script, this package inspects the input
dataset first. It records why each image was accepted, warned, rejected, or
unreadable and exports both human-readable and machine-readable evidence.
Analysis is local and contains no telemetry or network requests.
Installation
python -m pip install opencv-calibration-audit
Python 3.9–3.13 is supported. The implementation uses
findChessboardCornersSB, available in supported OpenCV 4.x releases and
OpenCV 5.x. The default dependency is the headless OpenCV wheel.
Five-minute quick start
calibration-audit analyze ./calibration_images \
--cols 9 \
--rows 6 \
--square-size 30 \
--unit mm \
--output ./audit_result
--cols and --rows always mean inner corners, not squares. A target with
10 × 7 squares has 9 × 6 inner corners.
Example terminal summary:
Quality gates: PASSED
Accepted views: 12
OpenCV RMS: 0.284931 px
Report: audit_result/report.html
Useful stricter options:
calibration-audit analyze ./calibration_images \
--cols 9 --rows 6 --square-size 30 --unit mm \
--recursive \
--min-valid-images 12 \
--min-board-area 0.05 \
--max-per-view-error 1.0 \
--fail-on-warning \
--output ./audit_result
The command will not overwrite a non-empty output directory unless
--overwrite-output is supplied.
Python API
from pathlib import Path
from calibration_audit import AuditConfig, PatternSpec, audit_dataset
config = AuditConfig(
pattern=PatternSpec(
cols=9,
rows=6,
square_size=30.0,
unit="mm",
),
min_valid_images=12,
)
result = audit_dataset(
image_directory=Path("./calibration_images"),
config=config,
)
print(result.summary)
result.write_outputs(Path("./audit_result"))
Library functions raise typed CalibrationAuditError subclasses and never
call sys.exit().
Output
audit_result/
├── report.html
├── summary.json
├── images.csv
├── calibration.yaml
├── accepted.txt
├── rejected.txt
└── assets/
├── coverage_heatmap.png
├── reprojection_errors.png
└── thumbnails/
report.html embeds its charts, CSS, and data images and works offline without
a CDN. Filenames are escaped. summary.json contains typed reason codes,
configuration, dataset metrics, quality gates, calibration parameters, and
per-image results. calibration.yaml uses an OpenCV-friendly matrix layout;
it does not claim ROS camera-info compatibility.
What is measured
- Detection rate: complete detections divided by readable images.
- Sharpness: variance of Laplacian globally and inside the detected board. With no user threshold, only clear dataset-relative outliers are warned.
- Exposure: mean grayscale intensity and near-black/near-white ratios.
- Board geometry: normalized center, area, rotation, perspective imbalance, and border distance.
- Coverage: occupied board-center cells in a 4 × 3 image-plane grid plus corner-observation density.
- Diversity: board-area distribution, occupied scale bins, rotation range, and horizontal/vertical perspective ranges.
- Duplicate pose: normalized position, log-area, rotation, and perspective thresholds. The sharper of two near-identical views is kept.
- Calibration: OpenCV pinhole RMS, camera matrix, distortion coefficients, extrinsics, and per-view reprojection statistics.
Per-view reprojection RMSE is:
sqrt(mean((projected_x - observed_x)^2 + (projected_y - observed_y)^2))
The coverage and diversity assessments are heuristics, not physical measurements or a calibration certificate. Sharpness values are especially dependent on resolution, target scale, focus, and lens characteristics.
The default near-duplicate component thresholds are: normalized center
distance 0.03, absolute log-area distance 0.08, wrapped rotation distance
5°, and combined perspective distance 0.08. These are typed policy values
in the Python API. The default relative-sharpness warning threshold is
0.35 × the dataset median.
Decisions and exit codes
Every rejection includes a stable reason code, severity, message, measured value, and relevant threshold. High reprojection-error views are flagged after the initial calibration and are not silently removed or recalibrated.
| Code | Meaning |
|---|---|
| 0 | Audit completed and quality gates passed |
| 1 | Audit completed but a configured quality gate failed |
| 2 | Invalid arguments or invalid input dataset |
| 3 | Unexpected processing/calibration failure |
Tracebacks are hidden by default and shown only with --log-level DEBUG.
Input behavior
Supported formats are JPEG, PNG, BMP, TIFF, and WebP. Files are processed in a deterministic sorted order. Unreadable images are reported individually. Mixed readable resolutions fail clearly and list their resolution groups. Source images are never deleted, moved, rewritten, or otherwise modified. Recursive discovery ignores symlinks that resolve outside the requested input tree.
Limitations
The MVP supports standard black-and-white checkerboards, monocular calibration, and the pinhole camera model. It does not support stereo or fisheye calibration, ChArUco/ArUco, circle grids, live capture, ROS output, a GUI, PDF reports, automatic view pruning, or input-file modification.
To generate a print-accurate target, use the companion
opencv-chessboard-generator.
Development
python -m pip install -e ".[dev]"
ruff check .
mypy .
pytest --cov=calibration_audit --cov-report=term-missing
python -m build
twine check dist/*
CI tests Python 3.9–3.13. Publishing is deliberately separate from ordinary CI and can run only for an explicitly published GitHub Release whose tag matches the project version.
License
MIT. See LICENSE.
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 Distribution
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 opencv_calibration_audit-0.2.0.tar.gz.
File metadata
- Download URL: opencv_calibration_audit-0.2.0.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
641c59cf3ef74785956ca12ea8d10fa6f7ce8a7e334af3bc0ecaf132b8ec9d8a
|
|
| MD5 |
f1706f29432978ee2ce73c525b943394
|
|
| BLAKE2b-256 |
908657014f8d98f412566117af6ce98f1154240988b312b53d2666c3ebaac6b5
|
Provenance
The following attestation bundles were made for opencv_calibration_audit-0.2.0.tar.gz:
Publisher:
release.yml on flavvesResearch/opencv-calibration-audit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opencv_calibration_audit-0.2.0.tar.gz -
Subject digest:
641c59cf3ef74785956ca12ea8d10fa6f7ce8a7e334af3bc0ecaf132b8ec9d8a - Sigstore transparency entry: 2291069708
- Sigstore integration time:
-
Permalink:
flavvesResearch/opencv-calibration-audit@47ef088df0b410796b67174998b5f2a0d591dc58 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/flavvesResearch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@47ef088df0b410796b67174998b5f2a0d591dc58 -
Trigger Event:
release
-
Statement type:
File details
Details for the file opencv_calibration_audit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: opencv_calibration_audit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec5ac2046ee3c407ec85474d933ab303cfc8b695fb9324c4fbce38cabc29bb0b
|
|
| MD5 |
85ee19d57049ff315aaa01308a844708
|
|
| BLAKE2b-256 |
fed57e839de0a2f40674649c627bfb4991275e7298690e1d786df18822940b27
|
Provenance
The following attestation bundles were made for opencv_calibration_audit-0.2.0-py3-none-any.whl:
Publisher:
release.yml on flavvesResearch/opencv-calibration-audit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opencv_calibration_audit-0.2.0-py3-none-any.whl -
Subject digest:
ec5ac2046ee3c407ec85474d933ab303cfc8b695fb9324c4fbce38cabc29bb0b - Sigstore transparency entry: 2291069758
- Sigstore integration time:
-
Permalink:
flavvesResearch/opencv-calibration-audit@47ef088df0b410796b67174998b5f2a0d591dc58 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/flavvesResearch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@47ef088df0b410796b67174998b5f2a0d591dc58 -
Trigger Event:
release
-
Statement type: