PyCalib: Simple Camera Calibration in Python for Beginners
Project description
Simple Camera Calibration in Python for Beginners
This is a collection of algorithms related to multiple-view camera calibration in computer vision. Please note that the goal of this package is to provide minimal examples to demostrate the concept for beginners (i.e., students). For large-scale, realtime, accurate, robust, production-quality implementations, or for implementations for your specific situation, please consult your advisor.
Disclaimer
This is research software and may contain bugs or other issues -- please use it at your own risk. If you experience major problems with it, you may contact us, but please note that we do not have the resources to deal with all issues.
How to use
You can simply install the package by pip
.
$ python3 -m pip install -U pycalib-simple
The pip installation, however, does not include examples in ./ipynb
. To run examples, download the repository explicitly. For example,
- Local: You can clone/download this repository to your local PC, and open
./ipynb/*.ipynb
files by your local Jupyter. - Colaboratory: You can open each Jupyter notebook directly in Google Colaboratory by clicking the buttons below.
- Warning: Most of them do not run properly as-is, since colab does not clone images used in the Jupyter notebooks. Please upload required files manually. (or run
!pip install
and!git clone
at the beginning of each notebook.)
- Warning: Most of them do not run properly as-is, since colab does not clone images used in the Jupyter notebooks. Please upload required files manually. (or run
Examples
- Extrinsic calibration of 15 GoPro cameras
- Given 2D-2D correspondences, this example calibrates the extrinsic parameters of 15 GoPro cams.
Single camera
- Intrinsic calibration with charuco images
- GoPro fisheye lens distortion is handled by the rational model in OpenCV
- Intrinsic calibration with chessboard images
- Zhang's method
- Extrinsic calibration w.r.t. a charuco board
- PnP with ChAruco
- Extrinsic calibration w.r.t. a chassboard
- PnP with chessboard
- Intrinsic / Extrinsic calibration with 2D-3D correspondences
- for non-planar reference objects
Multiple cameras
- Multi-view triangulation
- N-view DLT
- Sphere center detection for 2D-2D correspondences
- for extrinsic calibration using a ball
- 2-view extrinsic calibration from 2D-2D correspondences
- decomposes the essential matrix to R and t
- N-view registration
- A linear registration of pairwise poses into a single coordinate system
- N-view bundle adjustment
- A non-linear minization of reprojection errros
3D-3D
If you need to write your own calibration ...
In general, prepare some synthetic dataset, i.e., a toy example, first so that your code can return the exact solution up to the machine epsillon. Then you can try with real data or synthetic data with noise to mimic it.
Also you may want to read Section A6.3 "A sparse Levenberg-Marquardt algorithm" of the textbook "Multiple View Geometry in Computer Vision" by Hartley and Zisserman.
- Linear calibration: Use
numpy
. - Non-linear (including bundule adjustment): Try
scipy.optimize.least_squares
first.- Implement your objective function as simple as possible. You do not need to consider the computational efficiency at all. "Done is better than perfect."
- Test with the toy example and make sure that your objective function returns zero for the ground-truth parameter.
- If the above is unacceptably slow, try the followings in this order.
- Ask yourself again before trying to make it faster. Is it really unacceptable? If your calibration can finish in an hour and you do not do it so often, it might be OK for example. "Premature optimization is the root of all evil." (D. Knuth).
- Make sure that the optimization runs successfully anyway. In what follows, double-check that the optimization results do not change.
- Vectorize the computation with
numpy
, i.e., no for-loops in the objective function.- or use
numba
(e.g.@numba.jit
)
- or use
- If the system is sparse, use
jac_sparsity
option. It makes the optimization much faster even without analitical Jacobian. - Implement the analytical Jacobian. You may want to use maxima to automate the calculation, or you may use JAX or other autodiff solutions for this.
- Reimplement in C++ with ceres-solver or sba if the computation speed is really important.
- Implement your objective function as simple as possible. You do not need to consider the computational efficiency at all. "Done is better than perfect."
Contact
Please note that this is research software and may contain bugs or other issues -- please use it at your own risk. If you experience major problems with it, you may contact us, but please note that we do not have the resources to deal with all issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pycalib-simple-2023.12.14.1.tar.gz
.
File metadata
- Download URL: pycalib-simple-2023.12.14.1.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c4fe5ca4ef1cb5b41230cea021eec0c834806c5c4953a6d405d50ba4e4aa926 |
|
MD5 | afda7c4f30de7a707adde377015d9591 |
|
BLAKE2b-256 | 2ba5de5ac407a1881a36fb7e8e6a5286e31a33256d90790c73753533923991f5 |
Provenance
File details
Details for the file pycalib_simple-2023.12.14.1-py3-none-any.whl
.
File metadata
- Download URL: pycalib_simple-2023.12.14.1-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57465088e2de0b889366a1f49268b7a5ccb2cdee2f3276ade61e1f3f35e6c179 |
|
MD5 | 2302546832214615eee11bfbe8efd931 |
|
BLAKE2b-256 | 6abf5a4ec302ed1037d4b97d667ddeef5a6fe69104c895ef08c519c0f998cdeb |