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

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.1.0-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.0-cp312-cp312-macosx_11_0_arm64.whl (864.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.1.0-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.0-cp311-cp311-macosx_11_0_arm64.whl (863.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dac5098e0b36cb4cca3277d12cd8e5e9f4e1630cf236057d37c22b910221ead0
MD5 78c9e5ef08d8fce8de929411371fe9b1
BLAKE2b-256 79e1e8c79f730a36978b4135ca2b0bb98048f80bea9f992a90f6f27c4b529bc6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8234678be8e55b480cf1ec0432543944c2f8af510325fac433ab1d2aeca28ec1
MD5 046e7e757c64f64c69e69e89497202df
BLAKE2b-256 01c378dd4953a3af3698fa410639623ed72fb352ca19a45297ff750901725487

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76ec4598e637b15fd1690522ce9033acbb02d4d514d7794a11598ff23c056c79
MD5 ed58237748f4f2cf915754802407bfcf
BLAKE2b-256 4c5d9504863ef9c6033095710b128b0c17679ebc07893d6bef39ec94a7853c01

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6478abed0bdfb8b5986ab52dfc394f7dc67438584c2f85811e0089e45dd22bba
MD5 bc5d5a2133991ab0f37256e45612b513
BLAKE2b-256 7101ab5dfd8e2e60c0949e3596974f20b0f377184cbe6cc7dd51a357b23e28b9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78ff0b0ded496a71b633bda1dbb303971500ec397611d2bb7d071a3a332dfb92
MD5 e4f44e80882213efb0801605a348c333
BLAKE2b-256 6991d3a475aa6ab8495fa9ad5026ddf95dfb1743ca2040018b093d76c378a7cf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e6e179825013b2be79d082360dfc636fadb671a34f6f2b3b9d333d855ab8c97
MD5 a6e2ea04c25248b02b957a5e058da85a
BLAKE2b-256 56405dd307bd1ca58a7339b910d4120ee192c38d71f55af0b75a3ae6fee09c8c

See more details on using hashes here.

Provenance

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