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,
    ),
)

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,
    ),
)

Getting started

Read the calibration guide for a full walkthrough - calibrating a camera, verifying the results, and exporting for runtime use.

If you just want to see lensboy in action, see quickstart notebook.

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

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.

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-3.0.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

lensboy-3.0.1-cp314-cp314t-macosx_11_0_arm64.whl (948.1 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

lensboy-3.0.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

lensboy-3.0.1-cp314-cp314-macosx_11_0_arm64.whl (938.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

lensboy-3.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

lensboy-3.0.1-cp313-cp313-macosx_11_0_arm64.whl (938.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

lensboy-3.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

lensboy-3.0.1-cp312-cp312-macosx_11_0_arm64.whl (938.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lensboy-3.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

lensboy-3.0.1-cp311-cp311-macosx_11_0_arm64.whl (937.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file lensboy-3.0.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lensboy-3.0.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c41bfbccf60f602af550d7b3a1ad6d8d120189c9bf42ee96faf45cf056550a99
MD5 ababb100e342339364d3fad20a26d8c6
BLAKE2b-256 761dc74ed2b35b605d3112a20e140e561b4465f647083f60cd55ed034c8cc591

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-3.0.1-cp314-cp314t-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-3.0.1-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lensboy-3.0.1-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6fb0955ab0c4350b355902cc2313e70fa63cacf962179b952829616bf415824
MD5 17fc177e7a7b830ac99124f1f3310180
BLAKE2b-256 6095714eb8d0f93b52df8f6b083f2780293d6b0ba6c09281ce1b2cb92fcb7150

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-3.0.1-cp314-cp314t-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-3.0.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lensboy-3.0.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 940e1e27945765b5883e509397e7e6adcf5cdcb8c6313d3731263e0a44a9c0fd
MD5 d30a023cdd6e9020cefdd8504bfab2da
BLAKE2b-256 7938554f6eb972a705af713ec628c530ff05723ff45541135b31c64e290a5840

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-3.0.1-cp314-cp314-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-3.0.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lensboy-3.0.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36c4db6f8b1e4b1b0f849da54fe737680118b8c9bbd27fd5f87c9632a51efc8f
MD5 3584cf09d69962c09f5703b1ebeb9871
BLAKE2b-256 7f76385e9eede28296b478bebee74123da93cfe42d538936622f26314582d54a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lensboy-3.0.1-cp314-cp314-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-3.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lensboy-3.0.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bfb69e720422e9009390e4ea207415b47090b4c58ebf2eaf1e0698a0b653372a
MD5 2d2861243a9705885d8e21a2e7ea57f3
BLAKE2b-256 027f7d2fb7099719e9f6d5139a6ef811b23c07edf5ead902b5c67ae3ce5add39

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-3.0.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1f744df389d254e4c053e1eabef8a8802a08932b49d09a7976114d1dfdd6cb45
MD5 84be5d1f84a820ed91bd84335d95378f
BLAKE2b-256 755a01c237936d9fe89de8c332b532986e93efe63183e9f7f4a023a3e21ebbc1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-3.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 238491860ac2dc5e42cfadb01706218a677cf4a0b24165c3e1e6977c17b1196a
MD5 ead21a586c08f5a762bb54062991eacf
BLAKE2b-256 165baa2fa10ddfcbfa0b6fd5cbeb5eb721c351d3f193b81907e442eddc9cee8f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-3.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aedbb5e9714ec612939abfe1aaffc814f613df3e28af729ca4120c9266187cb0
MD5 9fcff2eaa7c664fae2387eddbff24ff8
BLAKE2b-256 58aca938088e64ab88514501420b4ce1d772f261632dceb4df5fb85ef7b1fed0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-3.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 495b5ac9ee34e0fd839159334525434b561f0c184dd4a5ba9bdeb11803623142
MD5 267279012f1816725ad9a595159cf8d1
BLAKE2b-256 61c6e3629ca0302a5252b39d644a2cbb5eb22b7926a7f2e966bb56f2bb900a30

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for lensboy-3.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c93e8dbabde7974d7def19571700cb69f70ce3d09820c3853e60bbf7eaf12d4
MD5 3084926300071ec6b1339a0f377928b4
BLAKE2b-256 ed590cbd447aa56f343854cd38744af58e84f1711ac3c5bc34248ee1cd5d6701

See more details on using hashes here.

Provenance

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