Skip to main content

lensboy for camera calibrations

Project description

lensboy

PyPI Python License

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


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.7-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.7-cp313-cp313-macosx_11_0_arm64.whl (855.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.0.7-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.7-cp312-cp312-macosx_11_0_arm64.whl (854.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.0.7-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.7-cp311-cp311-macosx_11_0_arm64.whl (854.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.0.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2bf33c389eb8542fbcb097acd2cd53b709f741ea303b16e7c6b81311910e6be0
MD5 5e7ee723e548db81f178c399b7cf823a
BLAKE2b-256 e70dc0374380aeabfc5f32ebf486748d8e78a608ef9fab08754e88ba480e4c0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.7-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.7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e84d77b6d19f3d8dea9d822c417ccb8905e4c4a237b51e0243b756ea025dc6e
MD5 250042175b8822c731fc00d3001d9095
BLAKE2b-256 5de8f6000fcbac39cd7dcc3ff818902a4170cdaa061f56d15bd8bfdc8396770e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.7-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.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1dd33c9aa551397a6181dbbb782f7329ab2c6ea8cfd5627da9a48cfd236425a7
MD5 18cb77d1f5af1fe34267365e4c6ac099
BLAKE2b-256 0c8b8e60c521af215a1c25a19d46c7131ff8696c55761d044ea6f2cbf51483e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.7-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.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 445bef4e382a2345cae912686939e55d0c27f250600013f1b80961c9b510770e
MD5 1224358e15a670f4ed72743ee325683a
BLAKE2b-256 6e1b3370ff5c5ba2d2a4709ed3083fffd4e5b371f8ae162bf1e495f551bb2ba2

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.7-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.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 944c3dbc16f87920f68aa83a09ca54dbb76215e3d6f5b1102770a9a973630f07
MD5 e094ff8b4621e9737cebc79752437e0f
BLAKE2b-256 968494fb884d6d71bc649cb0158b48a75cb1e578432bf47f156e32b2e8636216

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.7-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.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lensboy-1.0.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 627bbd4308b46d68ffe9464524092b9863b2c9ef4d956dad2fe3f7adbc0f93cf
MD5 89c682057370bd2308b34f4e99399071
BLAKE2b-256 5ac1a84cdf81a9c0b990dacdbfdfa7b3a34fb8c7df7c7fb1a304fd65b08d5c68

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-1.0.7-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