Skip to main content

lensboy for camera calibrations

Project description

lensboy

lensboy

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lensboy-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

lensboy-1.0.4-cp313-cp313-macosx_11_0_arm64.whl (854.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

lensboy-1.0.4-cp312-cp312-macosx_11_0_arm64.whl (854.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

lensboy-1.0.4-cp311-cp311-macosx_11_0_arm64.whl (853.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file lensboy-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8b16e6177f284893e3ce871d2c8e5b5399876690b6340c423d5dc92b0d0037d3
MD5 1a6da69c02319a9340fa76dac581b0c1
BLAKE2b-256 862278154dfacf70009bd4dc711a72456610be1316643e1fdb77a5cc00e5e3d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Robertleoj/lensboy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lensboy-1.0.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 71b917b4e42e6ce510daefe6abc7787b2116c96da5f7ad4d2b07c0b379b5aaa5
MD5 f3d651c44e3518fe4324aaf00aeb0a9b
BLAKE2b-256 c25616fb9f8b735625ef90a55ff8c450318188dcccd5887b4e8a18753d5ff9bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.4-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: wheels.yml on Robertleoj/lensboy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lensboy-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 781a873db36622b576d487336fbbb49e66b7ebbc19aa61f19478ae9e4a92a8f4
MD5 5c9b470583e14055ca5293ca29e35652
BLAKE2b-256 28725dfd45eb7047931d6ca8ef6ff442b5905aaf7b52071c59eb83ae72bab2fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Robertleoj/lensboy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lensboy-1.0.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24df4fe37effcc61c99210b8da366862b9a2bb646088112c6c13b8a024bbba2c
MD5 b5635939c8279aae23c38be0517bbc5a
BLAKE2b-256 4ed67ff48fd254534409d5066ade92ef7fb9b1fa0d0cbe8eb231f17bb918b2db

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.4-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: wheels.yml on Robertleoj/lensboy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lensboy-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 63049605a82d6715fb07e2a702012bea0f39f2f41387b157a0223d5f60b233bb
MD5 724d67fe2e815c39158bea262e64af93
BLAKE2b-256 fbb884a13277ba7ddf88340c54f11b2db0282bb58720115370f23bdc402f08df

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Robertleoj/lensboy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lensboy-1.0.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f8595c6b0b5357d16abcefb33a33d7c0974ab7de47480f2e8e5332ee6374c95f
MD5 906fba9d94ed8ae40235125848a04fcf
BLAKE2b-256 a6cb62606c4e64a2f67c54215a2660ef4b24f7156d37aec1857bcaebda3f3ce9

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.4-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: wheels.yml on Robertleoj/lensboy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page