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.
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 = 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, initial_focal_length=1000,
),
)
result.optimized_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, initial_focal_length=1000,
),
)
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
Getting started
See the quickstart notebook.
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:
pinhole = spline_model.get_pinhole_model()
undistorted = pinhole.undistort(image)
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-1.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-1.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.3 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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dac5098e0b36cb4cca3277d12cd8e5e9f4e1630cf236057d37c22b910221ead0
|
|
| MD5 |
78c9e5ef08d8fce8de929411371fe9b1
|
|
| BLAKE2b-256 |
79e1e8c79f730a36978b4135ca2b0bb98048f80bea9f992a90f6f27c4b529bc6
|
Provenance
The following attestation bundles were made for lensboy-1.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-1.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
dac5098e0b36cb4cca3277d12cd8e5e9f4e1630cf236057d37c22b910221ead0 - Sigstore transparency entry: 1013097472
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@524126fa9b582b642164a38481a7e2dcea3bad3e -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@524126fa9b582b642164a38481a7e2dcea3bad3e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.1.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: lensboy-1.1.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 864.1 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8234678be8e55b480cf1ec0432543944c2f8af510325fac433ab1d2aeca28ec1
|
|
| MD5 |
046e7e757c64f64c69e69e89497202df
|
|
| BLAKE2b-256 |
01c378dd4953a3af3698fa410639623ed72fb352ca19a45297ff750901725487
|
Provenance
The following attestation bundles were made for lensboy-1.1.0-cp313-cp313-macosx_11_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-1.1.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
8234678be8e55b480cf1ec0432543944c2f8af510325fac433ab1d2aeca28ec1 - Sigstore transparency entry: 1013097496
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@524126fa9b582b642164a38481a7e2dcea3bad3e -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@524126fa9b582b642164a38481a7e2dcea3bad3e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-1.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.3 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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76ec4598e637b15fd1690522ce9033acbb02d4d514d7794a11598ff23c056c79
|
|
| MD5 |
ed58237748f4f2cf915754802407bfcf
|
|
| BLAKE2b-256 |
4c5d9504863ef9c6033095710b128b0c17679ebc07893d6bef39ec94a7853c01
|
Provenance
The following attestation bundles were made for lensboy-1.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-1.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
76ec4598e637b15fd1690522ce9033acbb02d4d514d7794a11598ff23c056c79 - Sigstore transparency entry: 1013097525
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@524126fa9b582b642164a38481a7e2dcea3bad3e -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@524126fa9b582b642164a38481a7e2dcea3bad3e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: lensboy-1.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 864.1 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6478abed0bdfb8b5986ab52dfc394f7dc67438584c2f85811e0089e45dd22bba
|
|
| MD5 |
bc5d5a2133991ab0f37256e45612b513
|
|
| BLAKE2b-256 |
7101ab5dfd8e2e60c0949e3596974f20b0f377184cbe6cc7dd51a357b23e28b9
|
Provenance
The following attestation bundles were made for lensboy-1.1.0-cp312-cp312-macosx_11_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-1.1.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
6478abed0bdfb8b5986ab52dfc394f7dc67438584c2f85811e0089e45dd22bba - Sigstore transparency entry: 1013097543
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@524126fa9b582b642164a38481a7e2dcea3bad3e -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@524126fa9b582b642164a38481a7e2dcea3bad3e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-1.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.3 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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78ff0b0ded496a71b633bda1dbb303971500ec397611d2bb7d071a3a332dfb92
|
|
| MD5 |
e4f44e80882213efb0801605a348c333
|
|
| BLAKE2b-256 |
6991d3a475aa6ab8495fa9ad5026ddf95dfb1743ca2040018b093d76c378a7cf
|
Provenance
The following attestation bundles were made for lensboy-1.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-1.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
78ff0b0ded496a71b633bda1dbb303971500ec397611d2bb7d071a3a332dfb92 - Sigstore transparency entry: 1013097462
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@524126fa9b582b642164a38481a7e2dcea3bad3e -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@524126fa9b582b642164a38481a7e2dcea3bad3e -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.1.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: lensboy-1.1.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 863.2 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e6e179825013b2be79d082360dfc636fadb671a34f6f2b3b9d333d855ab8c97
|
|
| MD5 |
a6e2ea04c25248b02b957a5e058da85a
|
|
| BLAKE2b-256 |
56405dd307bd1ca58a7339b910d4120ee192c38d71f55af0b75a3ae6fee09c8c
|
Provenance
The following attestation bundles were made for lensboy-1.1.0-cp311-cp311-macosx_11_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-1.1.0-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
7e6e179825013b2be79d082360dfc636fadb671a34f6f2b3b9d333d855ab8c97 - Sigstore transparency entry: 1013097436
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@524126fa9b582b642164a38481a7e2dcea3bad3e -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@524126fa9b582b642164a38481a7e2dcea3bad3e -
Trigger Event:
push
-
Statement type: