Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

vision-calibration-py

Python bindings for calibration-rs.

This crate exposes the calibration workflows of vision-calibration to Python, with the Rust names: a one-call runner and a step-by-step session per workflow, manifest-driven runs from a folder of images, the target detectors on numpy images, and calibrated cameras that project numpy arrays.

Runner Session Workflow
planar_intrinsics.run_calibration PlanarIntrinsicsSession Planar intrinsics (pinhole or tilted Scheimpflug sensor)
single_cam_handeye.run_calibration SingleCamHandeyeSession Single-camera hand-eye
laserline_device.run_calibration LaserlineDeviceSession Camera + laser plane
rig_extrinsics.run_calibration RigExtrinsicsSession Multi-camera rig extrinsics
rig_handeye.run_calibration RigHandeyeSession Rig + hand-eye
rig_laserline_device.run_calibration RigLaserlineDeviceSession Rig laser plane (frozen rig hand-eye input)
rig_handeye_laserline.run_calibration RigHandeyeLaserlineSession Joint rig + hand-eye + laser plane

Install

pip install --pre vision-calibration   # the release candidate

To build from source instead:

maturin develop -m crates/vision-calibration-py/Cargo.toml

Python package

The Python package name is vision_calibration.

import vision_calibration as vc

print(vc.__version__)

# Build Python-native dataset/config objects with docstrings:
obs = vc.Observation(
    points_3d=[(0.0, 0.0, 0.0), (0.1, 0.0, 0.0), (0.1, 0.1, 0.0), (0.0, 0.1, 0.0)],
    points_2d=[(100.0, 100.0), (200.0, 100.0), (200.0, 200.0), (100.0, 200.0)],
)
dataset = vc.PlanarIntrinsicsInput(views=[vc.PlanarView(observation=obs)] * 3)
config = vc.PlanarIntrinsicsConfig(
    optimize=vc.PlanarOptimizeConfig(reprojection_loss=vc.robust_huber(1.0)),
    solver=vc.SolverConfig(max_iters=80),
)

result = vc.planar_intrinsics.run_calibration(dataset, config)
print(result.mean_reproj_error)

Tilted (Scheimpflug) sensor: select it in the camera model. By default the tilt is refined and only the leading distortion terms are free; list parameter names in CameraFix (for example CameraFix(sensor=["tilt_x"])) to fix others. Select it with vc.CameraConfig(model=vc.CameraModelSpec(sensor="scheimpflug")).

Every workflow takes its camera model the same way: the single-camera hand-eye and laserline-device configs have a camera field, and the rig configs take the same camera for every rig camera, plus camera_overrides to give individual cameras their own model and fix lists (vc.CameraOverride(camera=1, model=vc.CameraModelSpec(sensor="scheimpflug"))). Results report each camera as a CameraParams: its intrinsics plus one model per slot (projection, distortion, sensor), as configured.

Sessions and steps

A session runs a workflow step by step, with the Rust step names. Each step takes its options (a dataclass; None fields keep the config) and returns its result as a dataclass; the *_with_seed steps take manual-init seeds. The problem's results and its own seeds live in its module (vision_calibration.rig_extrinsics, ...); the intrinsics seeds several problems share, IntrinsicsManualInit (one camera) and RigIntrinsicsManualInit (each camera of a rig), sit next to the step options at the top level.

import vision_calibration as vc

session = vc.PlanarIntrinsicsSession()
session.set_input(dataset)
init = session.step_init_with_seed(
    vc.IntrinsicsManualInit(
        intrinsics=vc.PinholeIntrinsics(fx=800.0, fy=800.0, cx=640.0, cy=360.0)
    )
)
session.step_optimize(vc.IntrinsicsOptimizeOptions(max_iters=100))
result = session.export()
for entry in session.log:  # the init log and the solve notes
    print(entry.operation, entry.notes)
saved = session.to_json()  # resume later with PlanarIntrinsicsSession.from_json

Manifests and detection

calibrate_dataset runs a dataset manifest (TOML or JSON) end to end: detection, the problem's input, calibration and export. sniff_folder drafts a manifest from a folder; FsDetectionCache keeps detections between runs. A manifest that leaves a convention open raises AskUserError (a RunError) naming the field to set; other runner failures raise RunError with a kind.

manifest = vc.samples.fetch("kuka_1")       # a sample dataset, downloaded once
cache = vc.FsDetectionCache("cache/kuka_1")
result = vc.calibrate_dataset(manifest, cache=cache).export

vc.samples.catalogue() lists the sample datasets with their licence and citation.

The laser topologies take a laser_extractor: any object with a name and an extract(image, spec) method returning the laser line's (N, 2) pixels. detect_target runs a manifest's target detector on one (H, W) uint8 image and returns Features (image_xy and world_xyz arrays):

features = vc.detect_target(gray, {"kind": "chessboard", "rows": 17, "cols": 28, "square_size_m": 0.02})
view = vc.PlanarView(observation=features.to_observation())

Cameras and residuals

CameraModel builds a calibrated camera (any distortion model, identity or Scheimpflug sensor) and projects numpy arrays: project (N, 3) -> (N, 2), unproject to ray origins and directions, and undistort to an ideal pinhole image with the same intrinsics. Every result's per_feature_residuals holds the per-corner and per-laser-pixel residuals as numpy tables.

cam = vc.CameraModel(result.camera)
pixels = cam.project(points_cam)
res = result.per_feature_residuals
print(res.target.error_px.max(), res.target.observed_px.shape)

Uncertainty

Every result reports how well the data determines its parameters: result.uncertainty holds the covariance of the estimated parameters, the noise level the residuals imply and, when no covariance can be given, the reason. vc.projection_uncertainty(result, (width, height)) turns it into the standard deviation, in pixels, with which the camera places a ray in its image.

u = result.uncertainty
if u.available:
    print(f"fx = {result.camera.intrinsics.fx:.1f} +- {u.std_dev('fx'):.2f} px")
    print(f"corr(fx, cx) = {u.correlation('fx', 'cx'):.2f}")
else:
    print("no covariance:", u.reason, u.reason_labels)
p = vc.projection_uncertainty(result, (1280, 720))
print(f"projection sigma: centre {p.center:.3f} px, max {p.max:.3f} px")

Labels are parameter names such as "fx", "k1" or "tilt_x" (rig results prefix a camera, "cam1.fx"). The book's Uncertainty part explains how to read these numbers, the unavailable reasons and the rig caveats.

Multiple-view geometry

vision_calibration.mvg measures with a calibration: it takes a calibration result and returns triangulated points, object poses, bundle adjustments and laser points with their covariance (the calibration's share included), distances, angles and plane fits with their σ, stereo rectification and dense block matching. Poses are 4x4 numpy matrices and every σ is a numpy array.

import numpy as np
from vision_calibration import mvg

noise = mvg.reprojection_noise(result, camera=0)
tracks = [[mvg.RigObservation(0, 0, px0, noise), mvg.RigObservation(0, 1, px1, noise)]
          for px0, px1 in pixel_pairs]
found = mvg.triangulate(result, np.eye(4), tracks)
length = mvg.distance(mvg.PointSet.from_triangulation(found), 0, 1)
print(f"{length.value:.4f} m +- {length.sigma:.4f} m")

Runnable Python examples

Workflow examples live in crates/vision-calibration-py/examples/ and mirror the Rust examples in crates/vision-calibration/examples/. The real-image examples need the detector extras (pip install --pre "vision-calibration[examples]") and the datasets under data/ in the repository.

for f in crates/vision-calibration-py/examples/*.py; do python "$f"; done

vision_calibration.types is an advanced-interop surface for raw serde payloads; prefer the typed dataclasses/models for new code. Its TypedDicts are generated from the JSON Schemas of the Rust types (cargo xtask emit-schemas writes them, and CI fails when they are stale), so each carries its Rust name and shape: PlanarIntrinsicsConfig, CameraParams, Iso3, and one <Enum>_<Variant> type per variant of an enum with data, such as RobustLoss_Huber.

Metadata

Release files for vision-calibration 1.0.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vision-calibration 1.0.0rc1
File Size Uploaded Provenance Actions
vision_calibration-1.0.0rc1.tar.gz 1.5 MB With provenance Details for vision_calibration-1.0.0rc1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for vision-calibration 1.0.0rc1
File Interpreter ABI Platform Actions
vision_calibration-1.0.0rc1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for vision_calibration-1.0.0rc1-cp310-abi3-win_amd64.whl
vision_calibration-1.0.0rc1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for vision_calibration-1.0.0rc1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
vision_calibration-1.0.0rc1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for vision_calibration-1.0.0rc1-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 43.0 MB

Release files / vision_calibration-1.0.0rc1.tar.gz

Download URL vision_calibration-1.0.0rc1.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
7b0391890711d49b2523d686378c84ed0ea4bc45c6c439b8d8adeacd91ab21ce
BLAKE2b-256 checksum
How to use checksums
f81dd4f11862cc25b7ab43fca1841b64d4cbdc2d8bee67c998310d6877dd7dd4
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 Nov 18, 2026.

Transparency log

Release files / vision_calibration-1.0.0rc1-cp310-abi3-win_amd64.whl

Download URL vision_calibration-1.0.0rc1-cp310-abi3-win_amd64.whl
Size 13.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3451a554ac3b1066ff93ee04cad28fe7d908d36532def49409b2009d828b726b
BLAKE2b-256 checksum
How to use checksums
80936cdc5a7ad78561fe1a6c76ed6d1dc9683092826f2b97a3bece33cbc5e8ef
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 Nov 18, 2026.

Transparency log

Release files / vision_calibration-1.0.0rc1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL vision_calibration-1.0.0rc1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 14.3 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2a571e99d312081a071c754a8feadc27c480531d9b0fbed28eca80c37f1dd8b0
BLAKE2b-256 checksum
How to use checksums
e9c53871b215529d019e5c261fb56c3f17f733ab17bd623de54318126477ba01
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 Nov 18, 2026.

Transparency log

Release files / vision_calibration-1.0.0rc1-cp310-abi3-macosx_11_0_arm64.whl

Download URL vision_calibration-1.0.0rc1-cp310-abi3-macosx_11_0_arm64.whl
Size 13.9 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fec86c5289249608569ddb8f464529a3cf492f8d5dba055c9118217dcfa89006
BLAKE2b-256 checksum
How to use checksums
58f4fc7660f02b8d82745d6f52a18f400ebfad80e0e896da4facc6d3cca4532e
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 Nov 18, 2026.

Transparency log

Security for vision-calibration 1.0.0rc1

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.

Select from 4 files

Attestation for vision_calibration-1.0.0rc1.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 Nov 18, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page