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

Read the calibration guide for a full walkthrough on how to get good calibrations with lensboy.

For a quick code example, 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.

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-2.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aef7bdf963f07360439612609692b9786a4dfa6825b5c4ebd97848fe6bcc3079
MD5 8ba9d1951a3ec061b7d775db9fafc0eb
BLAKE2b-256 f26556310b97ed7ed75cf2f2b02dc758023f0383bd1e6c5f68ee069763af3839

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e7f191092d714d1fb77fedc4e48ec419925080bb06f702274b6113f0991c4e89
MD5 652b04aa4c23a627f4cc43d166096f79
BLAKE2b-256 ab2f84fabb63e14faa6ffe968b01eda1cdccb6f3a182732f3ed85cdd9de00c9d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e86f829297a631334c9241d4a006d60b174aa98180400dedd9db789f4bb98cda
MD5 b00718a1a45fbfc6eefd128429ddc1bb
BLAKE2b-256 d045490b895f8e71716cb0e53f8b7aa7b6c2c8f08c595c917be633da5ec75839

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed8973f3740fc9a5d3c4c1d29940157d89563a78c1dd83b66917616cd2ade4db
MD5 6b0b46b1e0cd58a896b0addf4e9da5a0
BLAKE2b-256 ef2aef632d34dadf53f055fe127044c7da2279d24e76cdf6056bd776938f091d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9023c4d914c7aa7917c7511298a1b5c2631dc844bd7c8cf9aa2a5a8e5724999
MD5 0f422547af4e9c5173d57dccb89fd5fc
BLAKE2b-256 d1c94ce5f35de20336df7f23b944c02ed89c77c49b8da6ffa0ffd85e7675f5f0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5bf41a698e5badc9338e3e83d339dbfb304ba4ac0dd6d4e2c8f64e5b9e1ece2
MD5 fdca5c24a395639017a2bd0ad7fd6ca6
BLAKE2b-256 bf1f8c567d01e6c3f338c0942e9003fd23b86cd638b80b7d5911b7c9c89e1cb9

See more details on using hashes here.

Provenance

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