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 (works with any target — charuco is just a built-in utility)
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.6-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.6-cp313-cp313-macosx_11_0_arm64.whl (855.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-1.0.6-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.6-cp312-cp312-macosx_11_0_arm64.whl (854.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-1.0.6-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.6-cp311-cp311-macosx_11_0_arm64.whl (854.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lensboy-1.0.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 54dc767abd2f12f7965a7d202e2da945fa75c704a2bfdc7b8c5a1b11bd2cf416
MD5 c81f604cc641efda2666a9f0c8a9c34b
BLAKE2b-256 e2d9e09b48fa83d232ae27d02fcf76037ad918f34b9a6e9f955370eba301c09f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00c0e694041ccfeade57be0e438a750f35302ecc2704a884be4ae7d344c3c5dc
MD5 5b390c59407682620591aaa3c55fe284
BLAKE2b-256 a81c76ddab213c1811f01196a99e606c05b103b850976d9c3df811bef9aff83b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e3dfe8a15b0f63be9334524b0eed883628d92aa031d1ba6d7723d487693ce1e6
MD5 148270107a05d00a9608f8051318bf6e
BLAKE2b-256 f535d5f84e230506514e92774974f8cddce56ca635c455a8dfc1cdd3b31e5c56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 206b7eab5f14538921aeb11bb633f69ed245406c732706cfeabe8f304ada6b77
MD5 9e61453576a839c8ffd9304f50a3fec1
BLAKE2b-256 caeca4787e40404c3de1dbeee3aef0c33e18834782a9be57e69a4b789ea0dbfe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7acf352f2bdaa5223aeedb71e73bf89fc62e5adb6e97818462398882f290d62f
MD5 b2bee500977011d654d9661ecdcfa30b
BLAKE2b-256 2f4b823b9f2039fd30b8e41916e81327743c76193cbc0da893eefbcc37a3de0f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-1.0.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12512eea1a287ffc44da877fb6f0db56e5e0d3b442eb2a4b34a58f2070788fd3
MD5 9f397a5405646ac4118609f4732ba36d
BLAKE2b-256 39316f2ac4817551578315c758415b6714775016b3ef8aa9a50258eb26ad38c2

See more details on using hashes here.

Provenance

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