Skip to main content

CalibrX SDK

Python Status OpenCV NumPy CLI License

CalibrX

The official Python SDK for the calibrx.io camera calibration platform.

Use CalibrX to bring platform-generated calibration results into your local computer vision workflows. Export a calibration from calibrx.io, load it in Python, and apply the same camera model, distortion coefficients, and undistortion settings in scripts, notebooks, production pipelines, or command line tools.

Features

  • Load CalibrX JSON and YAML calibration exports.
  • Support pinhole, pinhole_wide, and fisheye camera models.
  • Apply saved undistortion settings such as balance and fov_scale.
  • Override balance and fov_scale at runtime for local experiments.
  • Use either Python arrays, image files, or the CLI.
  • Work in scripts, notebooks, CI jobs, and batch processing pipelines.

Install

pip install calibrx

Quick Start

from calibrx import undistort_file

undistort_file(
    "input.jpg",
    "rectified_calibration.json",
    "output.jpg",
)

The calibration export decides the camera model and default undistortion settings. You can override them when needed:

from calibrx import undistort_file

undistort_file(
    "input.jpg",
    "rectified_calibration.yaml",
    "output.jpg",
    balance=0.5,
    fov_scale=1.0,
)

Notebook Usage

import cv2
import matplotlib.pyplot as plt
from calibrx import load_calibration, undistort

image = cv2.imread("input.jpg")
calibration = load_calibration("rectified_calibration.json")

result = undistort(image, calibration)

plt.figure(figsize=(14, 6))

plt.subplot(1, 2, 1)
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
plt.title("Original")
plt.axis("off")

plt.subplot(1, 2, 2)
plt.imshow(cv2.cvtColor(result.image, cv2.COLOR_BGR2RGB))
plt.title("Undistorted")
plt.axis("off")

plt.show()

If Jupyter cannot import calibrx, install a kernel from the same environment:

source .venv/bin/activate
python -m pip install ipykernel
python -m ipykernel install --user --name calibrx --display-name "Python (calibrx)"

Python API

from calibrx import (
    Calibration,
    load_calibration,
    undistort,
    undistort_image,
    undistort_file,
)

Load a Calibration

calibration = load_calibration("calibration.json")

print(calibration.camera_model)
print(calibration.image_size)
print(calibration.K)
print(calibration.D.reshape(-1))
print(calibration.balance)

Undistort an Image Array

import cv2
from calibrx import load_calibration, undistort

image = cv2.imread("input.jpg")
calibration = load_calibration("rectified_calibration.json")

result = undistort(image, calibration)

cv2.imwrite("output.jpg", result.image)
print(result.camera_matrix)
print(result.roi)

result.roi is the OpenCV valid-pixel ROI for pinhole models. Fisheye undistortion does not return an ROI, so the value is None.

Return Only the Image

from calibrx import undistort_image

undistorted = undistort_image("input.jpg", "rectified_calibration.json")

Handle Errors

from calibrx import CalibrationFormatError, UndistortionError

try:
    result = undistort("input.jpg", "rectified_calibration.json")
except CalibrationFormatError as exc:
    print(f"Invalid calibration export: {exc}")
except UndistortionError as exc:
    print(f"Could not undistort image: {exc}")

CLI Usage

Single image:

calibrx undistort input.jpg rectified_calibration.json output.jpg

Fisheye tuning:

calibrx undistort input.jpg rectified_calibration.json output.jpg \
  --balance 0.5 \
  --fov-scale 1.0

Batch a directory:

calibrx undistort ./frames rectified_calibration.json ./undistorted --glob "*.jpg"

The CLI prints every output path it writes.

Supported Exports

The SDK supports calibration exports from calibrx.io:

  • calibration.json
  • calibration.yaml
  • rectified_calibration.json
  • rectified_calibration.yaml

It expects OpenCV-ready intrinsics:

  • intrinsics.camera_matrix, or named fx, fy, cx, cy parameters.
  • intrinsics.distortion_coefficients, or named distortion parameters such as k1, k2, p1, p2, and k3.
  • camera_model: pinhole, pinhole_wide, or fisheye.

See docs/export-format.md for the full schema.

Development

For local development from this repository:

python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Run the test suite:

python -m pytest

Build and validate the package:

python -m build
python -m twine check dist/*

Run a quick local smoke test:

python - <<'PY'
import numpy as np
from calibrx import Calibration, undistort

print("calibrx import ok")

image = np.zeros((32, 48, 3), dtype=np.uint8)
calibration = Calibration.from_dict({
    "camera_model": "pinhole",
    "image_width": 48,
    "image_height": 32,
    "camera_matrix": [[40, 0, 24], [0, 40, 16], [0, 0, 1]],
    "distortion_coefficients": [0, 0, 0, 0, 0],
})

result = undistort(image, calibration)
print(result.image.shape)
print(result.camera_matrix.shape)
PY

License

MIT. See LICENSE.

Metadata

Release files for calibrx 0.1.0

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

Source distribution (sdist)

Source distribution for calibrx 0.1.0
File Size Uploaded Provenance Actions
calibrx-0.1.0.tar.gz 60.1 kB With provenance Details for calibrx-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for calibrx 0.1.0
File Interpreter ABI Platform Actions
calibrx-0.1.0-py3-none-any.whl Python 3 none any Details for calibrx-0.1.0-py3-none-any.whl

Total release size: 73.3 kB

Release files / calibrx-0.1.0.tar.gz

Download URL calibrx-0.1.0.tar.gz
Size 60.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4bf2e7860f9d2d8463303af0b71bf4b8e6211299ec858f66b44f5bcd0bd353c2
BLAKE2b-256 checksum
How to use checksums
e692192d07803e1abbca436ca305e128a7fa1860688999a47f3eddb81248881b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 6, 2026.

Transparency log

Release files / calibrx-0.1.0-py3-none-any.whl

Download URL calibrx-0.1.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
487a66ec9525b9948eab99d3f30cb06d95b8a537ab729794398519d2bfb27584
BLAKE2b-256 checksum
How to use checksums
aee868198c0db151031120256e995184bf7c931da366baf5a8f63ae92e2ae2f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 6, 2026.

Transparency log

Security for calibrx 0.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for calibrx-0.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 May 6, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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