A simple Python API for single camera calibration using opencv
A repository containing the camera calibration API
camera_calibration.py:contains an API which tries to minic the MATLAB's camera calibration app functionality. This API is a thin wrapper around the opencv's camera calibration functionalities.
examples: A directory containing various examples
The Camera Calibration API is a wrapper around the opencv's camera calibration functionalities. This tries to mimic the MATLAB camera calibration app's functionality in python
. The API supports all the 3 calibration patterns supported by opencv namely: Chessboards, Asymmetric circular grids and Symmetric circular grids. The API by default runs on 4 threads for speedup. The speed-up may not be marginal in the case of chessboard calibration because in most cases the bottle neck will be a single chessboard image (run on a single core) which the algorithm takes time to detect.
works in both python-3 and python-2
opencv (Tested in version 3.3.0)
numpy
matplotlib
pickle
argparse
glob
pickle
multiprocessing
os
pandas
Examples to use the Camera_Calibration_API() for calibration using chessboard, symmetric circular grids and asymmetric circular grids can be found in the example_notebooks folder
visualize_calibration_boards
method after calibration.Blob detection parameters
for detecting asymmetric and symmetric circular grids can be accessed and modified via the Camera_Calibration_API's object prior to calling the calibrate_camera
methodterminal
support with minimal control on the variables. Use it as an importable module for better control over the variablesSo you want to extend the API for a custom calibration pattern? Well... OK! Just follow the follow the steps below
calibrate_camera
accepts two additional arguments called custom_world_points_function
and custom_image_points_function
.calibrate_camera
methodNOTE: 'Custom' pattern is not supported when accessed from terminal
.
The code assumes that each asymmetric circle is placed at half the distance_in_world_units
in both (x,y) from each other.
The distance_in_world_units
is specified as the distance between 2 adjacent circle centers at the same y coordinate
The above is a 4 x 11 (r x c) asymmetrical circular grid.
If you are using the same orientation as the above, Then this orientation is termed as double_count_in_column which is by default set to True
.
If you are using an orientation which is 90deg to the above orientation 11 x 4 (r x c) then the double count
is along the rows. In this case, set object.double_count_in_column = False
prior to calling object.calibrate_camera
method.