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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d7f9d5154a525270a9009b60ad0011b12d4f3e6145b35f3bf4dc933fc0722d7e
MD5 8770c79b01b42373c030ae48cf01fa14
BLAKE2b-256 e739c7009ceda3610b83b2907b6f6daac0b7558ebf3b6f957a79fbf9bdb6a61f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d940fef274c583e5cfc374a6f78d2cd513f04b3b1d5f57e3e9f1d8eb51f6a39
MD5 38435d5a63fc810fd74a585f3ea7d165
BLAKE2b-256 0fe09f14d862f5b1423b16aaaeeac2497a5c82a814bae135beaf389c97c9c0e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 947a034a17cf001ae5cbfeb1fd78cff1afefa703e7c938b4c22420a12b65441c
MD5 02354d7f7f63e3aa5b37f3609eb94461
BLAKE2b-256 ea60d3fc051e01886af11f4f98ca3d347bea2d0200029c1537b4cc426d21207a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 87141940fe0f5946e5f421d0eac461f6a09c64e49513afaac8540d3c61597dc4
MD5 406e5cd3a880fd0bd440f33495f8df58
BLAKE2b-256 9c48725f366bcae8ca2a368238d527ee04a56571d1dc240940d46c3f6a0641e5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 893346e00cd53e1fd547623e6b010465b0cd2e5eda8ae1f3c9bca1f7aec6ba54
MD5 3b59ded588bf324df5becb7debce9f99
BLAKE2b-256 f118db7dc96a36ebb6cdcaa48b88728bbb67aa5d6fbad5673445805796780235

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a523db0f44eb68bbe5a879434e49cf1a94b4fa163060207befeb1d17a418df08
MD5 4f4631c5355758d310b39727be2e3c52
BLAKE2b-256 6ad6c57826eb0f7ba04611730dd2bac3d73dc919a60a2bea1e27137bd93b4634

See more details on using hashes here.

Provenance

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