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
Single camera
- Intrinsic parameters from chessboard images
- Extrinsic parameters w.r.t. a chassboard
- Intrinsic / Extrinsic parameters from 2D-3D correspondences
- Distortion
Multiple cameras
- Multi-view triangulation
- Sphere center detection for 2D-2D correspondences
- 2-view extrinsic calibration from 2D-2D correspondences
- N-view registration
- N-view bundle adjustment
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.
- 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.
- If it 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 if the computation speed is really important.
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
Hashes for pycalib-simple-2022.8.31.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63759c27b85e75c7282956ecb62073164a5a2dcfd8ca5632a68e3ba0aca141cc |
|
MD5 | c5743bb1e2be78a53bb6aa072df059bc |
|
BLAKE2b-256 | fdc19b88b52c66d186601744fd2ee32b3eb8e53554a4bcf322eec0acf30dde00 |
Hashes for pycalib_simple-2022.8.31.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c50516cfbf1b9ab128916ee15a4dd2b70db25f2199d99bb3956290cca993fc8 |
|
MD5 | 130989b7a9bb944be0f926f5fbb94eb1 |
|
BLAKE2b-256 | 6e0957916a8070c2ac071170cfb4c51c07210193820e949b5c2f2f180299ca94 |