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

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.0.3-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.3-cp312-cp312-macosx_11_0_arm64.whl (853.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.0.3-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.3-cp311-cp311-macosx_11_0_arm64.whl (853.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.0.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 28608c539c8d1949c218bbfe2f445d2bbb34d386cf3ee03a887d32999b774963
MD5 fe85f702cd244a9ff9b3ec508d43f50d
BLAKE2b-256 dabac0926d926b1fcd99009898653b04571540e095bff793cac5af09edf8f69f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd44822869f96b2529a3445715a3a6ea731f78513788d947e58d191dde4e60da
MD5 ddf614ed239ff4f213b20230b58e0354
BLAKE2b-256 ff1ac6101e3869029058d0e8c170a658826cc4254e1527639885d4482addfc62

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ad07aa06073c6d8c8cabd2c72fc55497e1ec086ee9816a2636c4c8e4b37965d4
MD5 451dadff0199e017d2e60ad69ee4d5b1
BLAKE2b-256 47c92d8d980b5aff0b3342c0c72fe80515a5e5325c993a475a26b06a4a0773a6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e06fc74ebf2662263341b3323f45fdc256044fb3df91590d45507a58a6cdf20a
MD5 f11da5aa3a0fe4b96caf9ee5b985118d
BLAKE2b-256 af30a9c99f8b4ab31850480b68f9d7d5ef51ba1b6597f1901b905165d2efa071

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d3bc1702e52c627abe4b843557e3d7a6539b4f835a30418676ca44e2b0e3bc2e
MD5 b3c27b54ba81b4686f7bf4b4ccce3db5
BLAKE2b-256 8ec01bab0b67263242066ae1998812597edc9b474994cf32afb2cc9fb45b4d22

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9e25953ec29367ce091e2986608f15b7bb10bdfaa864a6ea81ab6e33408e36f2
MD5 03679ef683fe9163f4a501912de3e0d8
BLAKE2b-256 a9b3e4cc1479dbb903e6501aea476fcb052e87928c26555f41482da119198a80

See more details on using hashes here.

Provenance

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