lensboy for camera calibrations
Project description
Camera calibration for vision engineers. Maximally powerful, minimally complex.
One job: fit camera models and verify the results. OpenCV models when they work, spline-based distortion when they don't.
Many of the techniques in this library were originally developed in mrcal.
Why lensboy
Even for standard OpenCV models, lensboy gives you better calibrations than raw cv2.calibrateCamera (see model comparison notebook):
- Automatic outlier filtering removes bad detections
- Target warp estimation compensates for non-flat calibration boards
For cheap or wide-angle lenses where OpenCV's distortion model isn't enough, lensboy offers spline-based models that can capture arbitrary distortion patterns.
Lensboy also offers analysis tools to verify your calibration is actually good.
Quick example
import lensboy as lb
target_points, frames, image_indices = lb.extract_frames_from_charuco(board, imgs)
result = lb.calibrate_camera(
target_points, frames,
camera_model_config=lb.OpenCVConfig(
image_height=h, image_width=w,
),
)
result.camera_model.save("camera.json")
Swap the config for a spline model — same API, more flexible:
result = lb.calibrate_camera(
target_points, frames,
camera_model_config=lb.PinholeSplinedConfig(
image_height=h, image_width=w,
),
)
Getting started
Read the calibration guide for a full walkthrough - calibrating a camera, verifying the results, and exporting for runtime use.
If you just want to see lensboy in action, see quickstart notebook.
Analysis tools
Plots for residuals, distortion, detection coverage, and model differencing. See the example notebooks.
Install
Full install, with analysis and plotting:
pip install lensboy[analysis]
Minimal install, for loading and using models:
pip install lensboy
Spline models
Spline models use B-spline grids instead of polynomial coefficients, so they can fit lenses that OpenCV's model can't. This approach is inspired by mrcal.
The calibrated model converts to a pinhole model with undistortion maps, so you can use it with any standard pinhole pipeline.
Runtime unproject LUTs
Iterative unprojection can be too slow for some applications.
UnprojectLUT caches normalize_points() on a regular pixel grid so
that per-pixel queries reduce to a bicubic interpolation. The cache is
saved as a directory of metadata.json + xy_grid.npy, loadable from
Python or from a small standalone C++ runtime in
cpp_runtime/.
import lensboy as lb
from lensboy.analysis import compute_lut_error_heatmap
model = lb.OpenCV.load("camera.json")
lut = model.get_unproject_lut(pixel_stride=32)
lut.save("camera_lut/")
runtime_lut = lb.UnprojectLUT.load("camera_lut/")
rays, valid_mask = runtime_lut.normalize_points(pixel_coords)
heatmap = compute_lut_error_heatmap(runtime_lut, model)
See the unproject LUT guide for sizing, interpolation modes, the file format, and the C++ runtime. There is also a runnable Jupyter notebook.
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 Distributions
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 lensboy-3.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.14t, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31ba040b73530d27e6ef8219ba27420107c450f5b058c6825c0697c0faede7b2
|
|
| MD5 |
b0c05ba60a80933b84bccd85e4643acc
|
|
| BLAKE2b-256 |
e86fea6a32af857bf9b09e0cb8e1b302e89f4167ada3b77ae88f0505c024cdeb
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
31ba040b73530d27e6ef8219ba27420107c450f5b058c6825c0697c0faede7b2 - Sigstore transparency entry: 1536960655
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp314-cp314t-macosx_15_0_arm64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp314-cp314t-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.14t, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d1f002baf7a01dbc18137c4646bb7a152c888e1aa9fe3bc8484634757011615
|
|
| MD5 |
4bdc196b07fb555041a62b6ad6336766
|
|
| BLAKE2b-256 |
a7d7cad1cf280bac480aee4602fda87bddd2b0ef2b579ffe222bba5662163714
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp314-cp314t-macosx_15_0_arm64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp314-cp314t-macosx_15_0_arm64.whl -
Subject digest:
2d1f002baf7a01dbc18137c4646bb7a152c888e1aa9fe3bc8484634757011615 - Sigstore transparency entry: 1536960595
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
accc43fbac3c5cc381bd7cc4cc7e9b652cf2e56bc352c46c500cee68b95e4061
|
|
| MD5 |
52abfb6d774c4c01335b92e30f2a7098
|
|
| BLAKE2b-256 |
202162a97176aaddd7c130a1e440c25b2cf00e63b259ce421e7f5c3818419484
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
accc43fbac3c5cc381bd7cc4cc7e9b652cf2e56bc352c46c500cee68b95e4061 - Sigstore transparency entry: 1536960612
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp314-cp314-macosx_15_0_arm64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp314-cp314-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.14, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52316bcf0f2a388e0b4ad7f5c0072430b0769655647098e7b4ddda63205bfcf9
|
|
| MD5 |
143a2c4731fe12d5fcab5cb2141d4a53
|
|
| BLAKE2b-256 |
1f0dba931fe8e85c20dff81f1c3e4ab07c5468c55624131472fd76015e2b3758
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp314-cp314-macosx_15_0_arm64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp314-cp314-macosx_15_0_arm64.whl -
Subject digest:
52316bcf0f2a388e0b4ad7f5c0072430b0769655647098e7b4ddda63205bfcf9 - Sigstore transparency entry: 1536960562
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a483ee6f6a8c6cded5cce0cb0caee0613f550718fb1a4b73fcbe4ce4c0073b7
|
|
| MD5 |
023f7f094dcfb4c03b594cd2e5329c1b
|
|
| BLAKE2b-256 |
ef395b1403f2098a5bac758a0b886195d92f80a966dc9f9dd8cafa16638bf9c2
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
7a483ee6f6a8c6cded5cce0cb0caee0613f550718fb1a4b73fcbe4ce4c0073b7 - Sigstore transparency entry: 1536960621
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.13, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e81e9859e41aa7dbb079466164044bca4867eb83bfa2b84d71ed21ef4a1fbbfb
|
|
| MD5 |
909831cc794e910c41e79fc3bc5f49cf
|
|
| BLAKE2b-256 |
89f8d17448948044418fab8261b49a9256c74c80bc8576f4aa88f8b2e1b4e690
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp313-cp313-macosx_15_0_arm64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp313-cp313-macosx_15_0_arm64.whl -
Subject digest:
e81e9859e41aa7dbb079466164044bca4867eb83bfa2b84d71ed21ef4a1fbbfb - Sigstore transparency entry: 1536960677
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31acb86549eee0021483670393f111c84f49ac402de0663e423ecbfaa482267e
|
|
| MD5 |
fdca9eede52df985ee8b72c39483552b
|
|
| BLAKE2b-256 |
3f619611387545bc4b40e04d1b42b76e0c740c33c858cd494a956d2aab7decbb
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
31acb86549eee0021483670393f111c84f49ac402de0663e423ecbfaa482267e - Sigstore transparency entry: 1536960571
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp312-cp312-macosx_15_0_arm64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp312-cp312-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
614ce98539994cdb9a7a61dacad0e83348426faea0d21e9c7347bfc4184d4bfb
|
|
| MD5 |
69d6cc4e3672f2a56e28464d82326051
|
|
| BLAKE2b-256 |
20fa12227ba899277e8568ad1268019f7dea6e9cca305ed0f116db9bf41843f5
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp312-cp312-macosx_15_0_arm64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp312-cp312-macosx_15_0_arm64.whl -
Subject digest:
614ce98539994cdb9a7a61dacad0e83348426faea0d21e9c7347bfc4184d4bfb - Sigstore transparency entry: 1536960578
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2041696171e6e0213f9af3f6d1723bc30518c8afcc478b8885b027cf0271f2e
|
|
| MD5 |
a55b80fe00e905d10b60bcb3bfb8a4c7
|
|
| BLAKE2b-256 |
8b878af7d04bbc8c814f2fa22ead4c00810c7405273b03815ccab4191340f0ab
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
b2041696171e6e0213f9af3f6d1723bc30518c8afcc478b8885b027cf0271f2e - Sigstore transparency entry: 1536960637
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-3.1.0-cp311-cp311-macosx_15_0_arm64.whl.
File metadata
- Download URL: lensboy-3.1.0-cp311-cp311-macosx_15_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04fc7cafacb889364c47ff198c64b0d03665a8f50137657f6d4f24e6054e4b7d
|
|
| MD5 |
c617c6ef68acf583e454824952707765
|
|
| BLAKE2b-256 |
f9d3bd9f5295eddac38cc78cab3cae07584e011d5f61ac9a292bcf952565dae7
|
Provenance
The following attestation bundles were made for lensboy-3.1.0-cp311-cp311-macosx_15_0_arm64.whl:
Publisher:
wheels.yml on Robertleoj/lensboy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lensboy-3.1.0-cp311-cp311-macosx_15_0_arm64.whl -
Subject digest:
04fc7cafacb889364c47ff198c64b0d03665a8f50137657f6d4f24e6054e4b7d - Sigstore transparency entry: 1536960585
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@420efc41aefdda27bd421da07ab0389382cb1a8e -
Branch / Tag:
refs/tags/v3.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@420efc41aefdda27bd421da07ab0389382cb1a8e -
Trigger Event:
push
-
Statement type: