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, as clearly demonstrated in the model comparison notebook. This is achieved mainly by two means:

  • Automatic outlier filtering removes bad detections
  • Target warp estimation compensates for non-flat calibration boards

For cheap or 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.

Lensboy also offers strong analysis tools to verify your calibration is actually good. These are demonstrated in the example notebooks.

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

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.0.8-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.8-cp312-cp312-macosx_11_0_arm64.whl (855.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.0.8-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.8-cp311-cp311-macosx_11_0_arm64.whl (854.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.0.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fd43f7e9cf7b689fe6860644677b1e71f10aef9c69d46f8b461e69336d483e3c
MD5 9958b8626450d771b9b0480038046f95
BLAKE2b-256 fcae9bbf22f5192f45fef6eb57c7a26c304b8744335df680dc19a458bca19ad2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 faed68202ee569c4b742b4fdc5e77de04aa0fd5898aa5990df92d3f592cb204b
MD5 432abe0b18ea1dcfdabc7f87dd9d6bf3
BLAKE2b-256 a93cea7af108d9db4a9f0b49fbe4b4fd4035350554650addcec5c35eeff7ccf4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dc7744344bb7490b83f91fe8d7a761f2b2a0dbcfcd51db4826967f8622eecf7d
MD5 9755d4c1e50a898d661d5e3ca2bf0bf1
BLAKE2b-256 a90788dde58235aa7482c79a45dc33f9008d8b67a58c185abeddc74dd290f7b4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cff59dd1525c1b6b7dc79024d5668296ba88e2bbb970281c0dd1abc84a327c5e
MD5 21bcfa3edfc502b14a209b3ee67f218a
BLAKE2b-256 9e6f1d71e322a42986b41c6b9fb5053b5fafa8c3b9f9303d3949d06d0fb225b1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 81185a7cc7e719099bea9a871d0acee3ff239dc3d41978194a669a5ee6a22014
MD5 031ccc6896e825ca74fd3815d6790b69
BLAKE2b-256 f4a3bd5127177eaf9a1222c77393fcfd389cca52345737102a3db118e77629c4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 154fb1dc81b8e28ed84f423c9b193379b20d3ac5efd71329223bd27ad42a2806
MD5 547bd90775758a5eba64723e0a94b921
BLAKE2b-256 0c5804fe2a985256168d3c0591dd91773d0fec9f26c7033f7cac933c5e00daa7

See more details on using hashes here.

Provenance

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