lensboy for camera calibrations
Project description
Camera calibration for vision engineers. Maximally powerful, minimally complex.
Supports OpenCV camera models and spline-based distortion models for lenses that OpenCV can't handle.
Quick example
import lensboy as lb
# detect calibration target in images (works with any target — charuco is just a built-in utility)
target_points, frames = lb.extract_frames_from_charuco(board, imgs)
# calibrate
result = lb.calibrate_camera(
target_points, frames,
camera_model_config=lb.OpenCVConfig(
image_height=h, image_width=w, initial_focal_length=1000,
),
)
# save
result.optimized_camera_model.save("camera.json")
Need more accuracy? Just swap the config — same API, way more powerful:
result = lb.calibrate_camera(
target_points, frames,
camera_model_config=lb.PinholeSplinedConfig(
image_height=h, image_width=w, initial_focal_length=1000,
),
)
Why lensboy
Even for standard OpenCV models, lensboy gives you better calibrations than raw cv2.calibrateCamera:
- Automatic outlier filtering removes bad detections
- Target warp estimation compensates for non-flat calibration boards
- Analysis tools to verify your calibration is actually good
For wide-angle lenses where OpenCV's polynomial distortion model isn't enough, lensboy offers spline-based distortion models that can capture arbitrary distortion patterns. This approach is inspired by mrcal, but lensboy is designed to be easier to use and trivial to install.
Install
For calibration time, includes analysis and plotting tools:
pip install lensboy[analysis]
For loading and using the camera models:
pip install lensboy
Getting started
See the quickstart notebook for a full walkthrough covering both OpenCV and spline models.
Spline models
When OpenCV's polynomial distortion model can't fully capture your lens, switch to a spline model. These use B-spline grids instead of polynomial coefficients, and can capture arbitrary distortion patterns.
The calibrated spline model can be converted to a pinhole model with undistortion maps, so you can use it anywhere:
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.0.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-1.0.6-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 |
54dc767abd2f12f7965a7d202e2da945fa75c704a2bfdc7b8c5a1b11bd2cf416
|
|
| MD5 |
c81f604cc641efda2666a9f0c8a9c34b
|
|
| BLAKE2b-256 |
e2d9e09b48fa83d232ae27d02fcf76037ad918f34b9a6e9f955370eba301c09f
|
Provenance
The following attestation bundles were made for lensboy-1.0.6-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.0.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
54dc767abd2f12f7965a7d202e2da945fa75c704a2bfdc7b8c5a1b11bd2cf416 - Sigstore transparency entry: 1006554042
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@95dca6674199818bd60d1d4c55069f58316964be -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@95dca6674199818bd60d1d4c55069f58316964be -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.0.6-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: lensboy-1.0.6-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 855.0 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 |
00c0e694041ccfeade57be0e438a750f35302ecc2704a884be4ae7d344c3c5dc
|
|
| MD5 |
5b390c59407682620591aaa3c55fe284
|
|
| BLAKE2b-256 |
a81c76ddab213c1811f01196a99e606c05b103b850976d9c3df811bef9aff83b
|
Provenance
The following attestation bundles were made for lensboy-1.0.6-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.0.6-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
00c0e694041ccfeade57be0e438a750f35302ecc2704a884be4ae7d344c3c5dc - Sigstore transparency entry: 1006554060
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@95dca6674199818bd60d1d4c55069f58316964be -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@95dca6674199818bd60d1d4c55069f58316964be -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-1.0.6-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 |
e3dfe8a15b0f63be9334524b0eed883628d92aa031d1ba6d7723d487693ce1e6
|
|
| MD5 |
148270107a05d00a9608f8051318bf6e
|
|
| BLAKE2b-256 |
f535d5f84e230506514e92774974f8cddce56ca635c455a8dfc1cdd3b31e5c56
|
Provenance
The following attestation bundles were made for lensboy-1.0.6-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.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
e3dfe8a15b0f63be9334524b0eed883628d92aa031d1ba6d7723d487693ce1e6 - Sigstore transparency entry: 1006554054
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@95dca6674199818bd60d1d4c55069f58316964be -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@95dca6674199818bd60d1d4c55069f58316964be -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.0.6-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: lensboy-1.0.6-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 854.9 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 |
206b7eab5f14538921aeb11bb633f69ed245406c732706cfeabe8f304ada6b77
|
|
| MD5 |
9e61453576a839c8ffd9304f50a3fec1
|
|
| BLAKE2b-256 |
caeca4787e40404c3de1dbeee3aef0c33e18834782a9be57e69a4b789ea0dbfe
|
Provenance
The following attestation bundles were made for lensboy-1.0.6-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.0.6-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
206b7eab5f14538921aeb11bb633f69ed245406c732706cfeabe8f304ada6b77 - Sigstore transparency entry: 1006554070
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@95dca6674199818bd60d1d4c55069f58316964be -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@95dca6674199818bd60d1d4c55069f58316964be -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: lensboy-1.0.6-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 |
7acf352f2bdaa5223aeedb71e73bf89fc62e5adb6e97818462398882f290d62f
|
|
| MD5 |
b2bee500977011d654d9661ecdcfa30b
|
|
| BLAKE2b-256 |
2f4b823b9f2039fd30b8e41916e81327743c76193cbc0da893eefbcc37a3de0f
|
Provenance
The following attestation bundles were made for lensboy-1.0.6-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.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
7acf352f2bdaa5223aeedb71e73bf89fc62e5adb6e97818462398882f290d62f - Sigstore transparency entry: 1006554035
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@95dca6674199818bd60d1d4c55069f58316964be -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@95dca6674199818bd60d1d4c55069f58316964be -
Trigger Event:
push
-
Statement type:
File details
Details for the file lensboy-1.0.6-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: lensboy-1.0.6-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 854.3 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 |
12512eea1a287ffc44da877fb6f0db56e5e0d3b442eb2a4b34a58f2070788fd3
|
|
| MD5 |
9f397a5405646ac4118609f4732ba36d
|
|
| BLAKE2b-256 |
39316f2ac4817551578315c758415b6714775016b3ef8aa9a50258eb26ad38c2
|
Provenance
The following attestation bundles were made for lensboy-1.0.6-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.0.6-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
12512eea1a287ffc44da877fb6f0db56e5e0d3b442eb2a4b34a58f2070788fd3 - Sigstore transparency entry: 1006554045
- Sigstore integration time:
-
Permalink:
Robertleoj/lensboy@95dca6674199818bd60d1d4c55069f58316964be -
Branch / Tag:
refs/tags/v1.0.6 - Owner: https://github.com/Robertleoj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@95dca6674199818bd60d1d4c55069f58316964be -
Trigger Event:
push
-
Statement type: