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 demonstrate 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 as follows.
python3 -m pip install -U pycalib-simple
Or to use the latest version, specifiy the github repository as follows. (visit https://pypi.org/project/pycalib-simple/ to check the latest version in PyPI)
python3 -m pip install -U git+https://github.com/nbhr/pycalib.git
Notice that the pip installation does not include examples in ./ipynb/ or tools in ./tools/. To run examples and tools, download the repository explicitly. For example,
- Local: You can clone/download this repository to your local PC, and open
./ipynb/*.ipynbfiles by your local Jupyter (e.g., VSCode + Jupyter plugin). - Colaboratory: You can open each Jupyter notebook directly in Google Colaboratory by clicking the
buttons below.
- Most of them do not run properly as-is, since colab does not clone image/data files used in the Jupyter notebooks. Please upload required files manually. (or run
!pip installand!git cloneat the beginning of each notebook.) - The scripts in
./tools/are not supposed to run in Colab/Jupyter.
- Most of them do not run properly as-is, since colab does not clone image/data files used in the Jupyter notebooks. Please upload required files manually. (or run
Usage
[Example] Calibration of 15 GoPro cameras
- Intrinsic calibration
- Intrinsic camera calibration from a video of ChAruCo pattern.
- GoPro fisheye lens distortion is handled by the rational model in OpenCV
- 2D keypoint detection
- ChAruCo corner detection to find 2D-2D corresponding points between cameras.
- Extrinsic calibration
- Extrinsic camera calibartion from 2D-2D correspondences.
- Scale / orientation alignment
- Scale / orientation alignment of the world coordinate system by capturing an AruCo marker on the floor.
Single camera
- Intrinsic calibration with charuco images
- 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 chessboard
- PnP with chessboard
- Intrinsic / Extrinsic calibration with 2D-3D correspondences
- for non-planar reference objects
Multiple cameras
- Multi-view triangulation
- N-view DLT
- Robust brute-force multi-view triangulation
- Robust but brute-force n-view DLT with occlusion handling and outlier rejection
- ChAruco diamond marker detection for 2D-2D correspondences
- For extrinsic calibration using a ChAruco diamond marker.
- Also can be used for PnP, i.e., extrinsic calibration w.r.t. the diamond marker
- 2-view extrinsic calibration from 2D-2D correspondences
- Decomposition of 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 errors
- Each camera can specify the parameters to optimize and to share with each other
- N-view time sync
- GoPro compatible QR time sync pattern generator, detector, and offset estimator
- Homography
- Homography from one camera plane to another
- Stereo rectification
- Horizontal / vertical stereo rectification for multi-view system and triangulation in WCS
Mirror
- Mirror-based extrinsic camera calibration
- Extrinsic calibration of a camera w.r.t. a reference object not directly visible from the camera.
- This is an implementation of
Takahashi, Nobuhara and Matsuyama "A New Mirror-based Camera Pose Estimation Using an Orthogonality Constraint," CVPR 2012.
- Display-camera calibration with mirrors
- How to calibrate a webcam w.r.t. a display using a ChAruCo pattern.
3D-3D
Circle / Sphere
- 3D circle estimation
- 3D circle center / normal estimation from its 2D projection, i.e., 2D ellipse.
- Sphere center estimation
- 3D sphere center estimation from its 2D projection, i.e., 2D ellipse.
- For extrinsic calibration using a ball.
- A color-based ball detection is provided as
tools/detect_by_color_gui.pyandtools/detect_by_color.py. The former GUI version can be used to sample foreground and background pixel colors, and the latter can be used to process each frame.
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_squaresfirst.- Implement your objective function as simply 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 your simple objective function 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 calibration runs successfully anyway. In what follows, double-check that the calibration results do not change before and after the code optimization.
- 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_sparsityoption. It makesscipy.optimize.least_squaresmuch 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, g2o, or sba if the computation speed is really important. You can also consider using PyTorch/Tensorflow for GPU-acceleration and autodiff by Theseus or similar libraries.
- Implement your objective function as simply 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.
Release files for pycalib-simple 2026.7.22.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pycalib_simple-2026.7.22.1.tar.gz | 57.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pycalib_simple-2026.7.22.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:102.3 kB
Release files / pycalib_simple-2026.7.22.1.tar.gz
| Download URL | pycalib_simple-2026.7.22.1.tar.gz |
|---|---|
| Size | 57.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e56a88121d16d5663384e583b178b0fd8fcd2bfc16f35e2498fefed435a604c7
|
|
BLAKE2b-256 checksum How to use checksums |
8f0007749fb15ea3abc1a869b91a547b517438299a767eee050cf88ea50b1a7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.
Transparency logRelease files / pycalib_simple-2026.7.22.1-py3-none-any.whl
| Download URL | pycalib_simple-2026.7.22.1-py3-none-any.whl |
|---|---|
| Size | 44.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1c0a0baf0cadad71cba326acfca9cfd622aa5370eb3353b0f7944b77b9089c5
|
|
BLAKE2b-256 checksum How to use checksums |
b332fb3c3136e6af97031e707e9215d27ec9599cdc68c66f7b141e8952ca6ff0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 22, 2026.
Transparency log