Skip to main content

lensboy for camera calibrations

Project description

lensboy

lensboy

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

Supports OpenCV camera models and spline-based distortion models for lenses that OpenCV can't handle.



Quick example

import lensboy as lb

# detect calibration target in images
target_points, frames = lb.extract_frames_from_charuco(board, imgs)

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

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

Need more accuracy? Just swap the config — same API, way more powerful:

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

Why lensboy

Even for standard OpenCV models, lensboy gives you better calibrations than raw cv2.calibrateCamera:

  • Automatic outlier filtering removes bad detections
  • Target warp estimation compensates for non-flat calibration boards
  • Analysis tools to verify your calibration is actually good

For wide-angle lenses where OpenCV's polynomial distortion model isn't enough, lensboy offers spline-based distortion models that can capture arbitrary distortion patterns. This approach is inspired by mrcal, but lensboy is designed to be easier to use and trivial to install.

Install

For calibration time, includes analysis and plotting tools:

pip install lensboy[analysis]

For loading and using the camera models:

pip install lensboy

Getting started

See the quickstart notebook for a full walkthrough covering both OpenCV and spline models.

Spline models

When OpenCV's polynomial distortion model can't fully capture your lens, switch to a spline model. These use B-spline grids instead of polynomial coefficients, and can capture arbitrary distortion patterns.

The calibrated spline model can be converted to a pinhole model with undistortion maps, so you can use it anywhere:

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

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.0.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.0.2-cp312-cp312-macosx_11_0_arm64.whl (850.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.0.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.0.2-cp311-cp311-macosx_11_0_arm64.whl (849.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4375e6dd9d122cd6584e042edf2445d4e26b9ba8bca2551ecb8cdab94574ff1d
MD5 c83b4d06f6177fe42f69bd200ddd64ef
BLAKE2b-256 bfee27be633764826bafd94e6a4c0969b6d64b7f484ad69fcf457d3f54deb436

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2dccc909f85faf47e3b10507bca2c4de7cfba37ad55711cd6e2a7b06fb426c85
MD5 a09485dcae997ce3a2be7e7a244a5364
BLAKE2b-256 33fbcdd5944c80d9d0c7834fdbe1a38bdde11bf161b723516ff86961b1d5e1cb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7edc3a76b7ad7446a8d872ee87e1adb8d2667ccb6473f1b3be0b83c1525b082d
MD5 f4c8e9ddf7328b615996049487cc0e95
BLAKE2b-256 6a90b2eac57fd932471616659173774a7cfa2735f896adc9f745dfa5f75f44a7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9af1f06c06880698d6a6ae38a9f7bbdda565abe09c3cb5420911fec98bb696e9
MD5 566809e72d8f7a43b285325fd742068e
BLAKE2b-256 17d1bd4bdc73bd9601177ed91a8930ef0bf8778f4096a7bbbbc8c60ae4459444

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4a34e48c85eab321271aa544399ca6988d304904a21b7184176f1ee15e25f2df
MD5 28ab72e8200774c854a5d743e0658105
BLAKE2b-256 13c539d69ab7e478d02d20f10a05147dd25089e5bc6d9b804de70e701b08d946

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2307e1988570cab8ccf78d70ee6ba6ce5f2f81655a50405b8ddf31f564a6c30
MD5 977983650ba62a0897cde7a585bd8727
BLAKE2b-256 39de9cd831953b79350c159ec26a95396ef15b9734a2df27063b0a2aa3d51d7d

See more details on using hashes here.

Provenance

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