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

See the quickstart notebook and the calibration guide.

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-2.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-2.1.0-cp313-cp313-macosx_11_0_arm64.whl (839.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-2.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-2.1.0-cp312-cp312-macosx_11_0_arm64.whl (839.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-2.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-2.1.0-cp311-cp311-macosx_11_0_arm64.whl (838.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-2.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a7dc2afa47e6a7658f1980e809462fc99c8badf47fe2786896cca566628d4b55
MD5 d708f41f845d203e45d3868d8562baa3
BLAKE2b-256 53569fb88514828dfa0c48f086944dc4049f35154e4736e3519d82da3464f010

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1637ab223c1452669bfde006e4088d5c9ec86d601fafacbb2f33bd1fe5a5cfa7
MD5 4c1823fd2bcf36e04da624a29ca64009
BLAKE2b-256 586e9fce053dd4abfbb291f8fe5c76518612da859c27a1b1562ad7a71bb616d1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 856440dc7fb14cc84623f5cf9653472f48888e6a6b715adbb00779a69f2175a3
MD5 014b77f027b4e1dd8b8534eeb5d774ec
BLAKE2b-256 f1b079348138ff771cb18fda8bb759185baca3f1980700b850b10e4c9d491afc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b42a2cbc821049daa0b42e1970e25500acc9cba261e5e0ea091f3fd5da6bb1c
MD5 4c4bbb95da034a237b49d7503410a3bc
BLAKE2b-256 1ca53220c3ea38050fdfcc2174d2221057b10932d7885689bb89971dafb3088a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fd9c66a1c8acd3f00f5fce7e86c8350c82217040d351c2f61bf33edc670af580
MD5 794291ce075e7b61f5b0acc955d0fd5a
BLAKE2b-256 2dd25758b106f62a8b4f48c284de9af89cd1a75f62a5dd77cd9a7b6e7ba05e40

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-2.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80fe8d2ea030dc1b06b1f9fb798c13db797add4b8eae64171c6c7118bdde1aad
MD5 efa9725752c2b019d97785a047941155
BLAKE2b-256 bc3b36e7fc4dc607b0a5fbb48999e43ead1b51d5345eb57089b6ba80e0a292e3

See more details on using hashes here.

Provenance

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