Skip to main content

lensboy for camera calibrations

Project description

lensboy

PyPI Python License

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

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.0.5-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.5-cp312-cp312-macosx_11_0_arm64.whl (854.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.0.5-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.5-cp311-cp311-macosx_11_0_arm64.whl (853.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.0.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3b58098f50333c4898437007ff3cca050a79cb110f42ffb570df20d6fd694f82
MD5 a7373340a858747f63456761e080ba24
BLAKE2b-256 226ae25d716964707c6795e37d9e64e8e5f95464dda2b4748373539320a74fe1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8810194a28ec6915be7769d5638e9b4227bd1924f6264659681e2093c44db0a9
MD5 7033903c92bbf35210610af14eb143bd
BLAKE2b-256 b607ccefd6315ec9b2da5cc72c9887801e1e3b6265f97241ee14342ffafc6392

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae276ad6a7f530c83d73fed9b1a6394f415b5364074e8d62f2ed9a88fc6d8606
MD5 16e8fc7bc9a9989cb2cdbebacc705e62
BLAKE2b-256 147bfbfcadee27ee23628218045bf211e18d6057c17c4bae072653f1a2de6d3f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 392ead2b7b6c26bf087f962f2409bf0ac6772960a83881f55b8997cd02789101
MD5 ad8438931492f9c391422c30ab3c4f40
BLAKE2b-256 176ea84a411b725e4e57f3cf37b15e71ee13ab078608f63dffe82710b2dc07eb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 884182f5076c3dd0acb2e37eefb7044bace01124fa68a02a6299a14158400fff
MD5 60bf964ce75016df805860738c49d184
BLAKE2b-256 3172b275d9455b98d183b451bce531d01f9dd7698dbc01f8093ef609a62be4ec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6aa93fdf141546f7228c73ef26cc046dbd9cc6a7f8726c9b844b91a12296e299
MD5 bac351d075752dfaa770f2ff228694d6
BLAKE2b-256 141ce6927e1168103d2584a1bea79189a06b7203d473dee59faed9dda0ae6dcc

See more details on using hashes here.

Provenance

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