Camera calibration is used to correct lens distortion, but it seems difficult to understand how each coefficient affects it.
So I will try to make it intuitive.
Unless it is an ideal pinhole camera model, the image will be distorted as shown on the left. By finding the distortion coefficient unique to the camera, it is possible to correct such a distorted image.
When you calibrate your camera, you print something called a checkerboard.
Take dozens of photos from all angles with the camera whose parameters you want to measure.
Now you can match the 2D coordinate $ x $ of the camera with the 3D coordinate $ X $ of space.
x = P X
This $ P $ is the camera matrix. It can be calculated by simultaneous equations with 3 rows and 4 columns.
P = K [R|t]
$ P $ can be decomposed into the upper triangular matrix $ K $ and the orthonormal matrix $ R $,
$ K $ ...... Internal Parameter, Intrinsic Parameter (focal length, optical center, shear coefficient) $ [R | t] $ ... External parameter, Extrinsic Parameter (Camera rotation and conversion)
It will be.
This internal parameter $ K $
K = \begin{pmatrix}
f_x & s & c_x \\
0 & f_y & c_y \\
0 & 0 & 1 \\
\end{pmatrix}
It represents the focal length $ (f_x, f_y) $, the optical center $ (c_x, c_y) $, and the shear coefficient $ s $.
In Python, you can use OpenCV to find $ K $ (mtx) as follows.
#Detect points from checkerboard
ret, corners = cv2.findChessboardCorners(gray, (8,6), None)
#Calibration
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, img_size,None,None)
#Distortion correction
dst = cv2.undistort(img, mtx, dist, None, newMtx)
Let's animate parameters such as focal length, optical center, and shear coefficient, respectively. Only the target parameters are changed from the obtained camera matrix.
Infinity → Appropriate focal length → Small
(1)
(2)
(3)
Negative → proper position → positive
(1)
(1)
Negative → proper value → positive In English it is Skew.
How was that. It turns out that camera calibration is used to correct distortion.
I also want to do the strain coefficient in the radial direction and the strain coefficient in the circumferential direction.
https://github.com/DavidWangWood/Camera-Calibration-Python https://jp.mathworks.com/help/vision/examples/evaluating-the-accuracy-of-single-camera-calibration.html