Skip to main content

lensboy for camera calibrations

Project description

lensboy

PyPI Python License

Camera calibration for vision engineers. Maximally powerful, minimally complex.

One job: fit camera models and verify the results. OpenCV models when they work, spline-based distortion when they don't.

Why lensboy

Even for standard OpenCV models, lensboy gives you better calibrations than raw cv2.calibrateCamera (see model comparison notebook):

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

For cheap or wide-angle lenses where OpenCV's distortion model isn't enough, lensboy offers spline-based models that can capture arbitrary distortion patterns.

Lensboy also offers analysis tools to verify your calibration is actually good.

Quick example

import lensboy as lb

target_points, frames, image_indices = lb.extract_frames_from_charuco(board, imgs)

result = lb.calibrate_camera(
    target_points, frames,
    camera_model_config=lb.OpenCVConfig(
        image_height=h, image_width=w, initial_focal_length=1000,
    ),
)

result.optimized_camera_model.save("camera.json")

Swap the config for a spline model — same API, more flexible:

result = lb.calibrate_camera(
    target_points, frames,
    camera_model_config=lb.PinholeSplinedConfig(
        image_height=h, image_width=w, initial_focal_length=1000,
    ),
)

Analysis tools

Plots for residuals, distortion, detection coverage, and model differencing. See the example notebooks.



Install

Full install, with analysis and plotting:

pip install lensboy[analysis]

Minimal install, for loading and using models:

pip install lensboy

Getting started

See the quickstart notebook.

Spline models

Spline models use B-spline grids instead of polynomial coefficients, so they can fit lenses that OpenCV's model can't. This approach is inspired by mrcal.

The calibrated model converts to a pinhole model with undistortion maps, so you can use it with any standard pinhole pipeline:

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

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.1.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.1.3-cp312-cp312-macosx_11_0_arm64.whl (835.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.1.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.1.3-cp311-cp311-macosx_11_0_arm64.whl (834.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.1.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b8782fadc03b6424b40ab3518e844a89ca8d7b3cbb3062e21e87c2b6706bc457
MD5 a9efd206a2b91c8d135e63bb9490df94
BLAKE2b-256 6f95440a84b01eaeaee947cecaeb030ddded1434e9ce023a9a098929e434f667

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9eb8a3fc72a2828f640dd2ddbe04d21f982b90164edc47044417b7747d7c94fd
MD5 c7c74e9861e989bae9264d7ef1f18e77
BLAKE2b-256 5cfc999bd9f91da8664493e9997693521f383ec7c4fd12487e75e58855d3d250

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7e922214b2d6e97c4550d0c7d30354ef462161d83fc2bdb748f138de95890d89
MD5 a26eb0e1740c65be2a0ff758062124f9
BLAKE2b-256 eeb24d2ab699e118ebddc6ee55eefdaff24f89e415dc5d5690e720ad5356ff3e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6cc2a0ee98da7cb03b9444384a8edd24339b122769e7e6a62d27acc012ff5efc
MD5 fdc870878f898642c91c541e63cb2ed2
BLAKE2b-256 c41838a951b056ba4b3e49837426c988e951addc1b4d0efcfce321ace5693bbb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b9cb68fc42498bc926e49505a22c0926dcaae59bb5907bf0a0766d8d7b261c1
MD5 6d22a07911aeb924948adda4c898da74
BLAKE2b-256 6b6a9f5eeff6fd1c31e00e2ab9b9521cfef0ac8ab58a77c6a52a476e4ad68f77

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d5f70c8e84095ec10d32842b8c0d4d102bde628e6df39aff05a017d2a0bcf7d
MD5 da7b6f6cc3671f64cc99a20f90e92f67
BLAKE2b-256 9c66b67c12e043e3823ba8610a2a9299e1327b1bc7c009b0a340cb269b778510

See more details on using hashes here.

Provenance

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