Package: pycalib-simple
Simple Camera Calibration in Python for BeginnersThis is a collection of algorithms related to multiple view camera calibration in computer vision.  Please note that the goal of this package is to provideminimalexamples 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.DisclaimerThis 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 useYou can simply install the package bypip.$ python3 -m pip install -U pycalib-simpleThe 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/*.ipynbfiles by your local Jupyter.Colaboratory:You can open each Jupyter notebook directly in Google Colaboratory by clicking thebuttons 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 installand!git cloneat the beginning of each notebook.)ExamplesExtrinsic calibration of 15 GoPro camerasGiven 2D-2D correspondences, this example calibrates the extrinsic parameters of 15 GoPro cams.Single cameraIntrinsic calibration with charuco imagesGoPro fisheye lens distortion is handled by the rational model in OpenCVIntrinsic calibration with chessboard imagesZhang's methodExtrinsic calibration w.r.t. a charuco boardPnP with ChArucoExtrinsic calibration w.r.t. a chassboardPnP with chessboardIntrinsic / Extrinsic calibration with 2D-3D correspondencesfor non-planar reference objectsMultiple camerasMulti-view triangulationN-view DLTChAruco diamond marker detection for 2D-2D correspondencesfor extrinsic calibration using a ChAruco diamond markeralso can be used for PnP, i.e., extrinsic calibration w.r.t. the diamond markerSphere center detection for 2D-2D correspondencesfor extrinsic calibration using a ball2-view extrinsic calibration from 2D-2D correspondencesdecomposes the essential matrix to R and tN-view registrationA linear registration of pairwise poses into a single coordinate systemN-view bundle adjustmentA non-linear minization of reprojection errrosN-view time syncAruco / Aruco diamond video maker for multi-view time sync3D-3DAbsolute orientation (or similarity transform) between corresponding 3D pointsIf 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:Usenumpy.Non-linear (including bundule adjustment):Tryscipy.optimize.least_squaresfirst.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 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 optimization runs successfully anyway.  In what follows, double-check that the optimization results do not change before and after the optimization.Vectorize the computation withnumpy, i.e., no for-loops in the objective function.or usenumba(e.g.@numba.jit)If the system is sparse, usejac_sparsityoption. It makes the optimization much faster even without analitical Jacobian.Implement the analytical Jacobian. You may want to usemaximato automate the calculation, or you may useJAXor other autodiff solutions for this.Reimplement in C++ withceres-solverorsbaif the computation speed is really important.ContactPlease 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 maycontact us, but please note that we do not have the resources to deal with all issues.