How do I generate distortion coefficients and camera matrix for cv2.aruco.calibrateCameraCharucoExtended()
?
I am calibrating camera using opencv-python 4.6
in built the cv2.aruco.calibrateCameraCharucoExtended().
I try to initialize the distortion coefficients
and the camera matrix
for this function, but i am not realy sure how to do this.
For the distortion coefficients
i create a numpy
array with Zeros.
distCoeffs=np.zeros((1,14))
(ret, camera_matrix, dist_coeffs,
rotation_vectors, translation_vectors,
std_deviationsion_intrinsics, std_deviations_extrinsics,
per_view_errors) = cv2.aruco.calibrateCameraCharucoExtended(
charucoCorners=cornersList, # charuco corners (box bounder)
charucoIds=idList, # charuco ids
board=board, #
imageSize=imageSize, # gray.shape
cameraMatrix=?, #
distCoeffs=np.zeros((1,14)), # initialized distortion coefficient 14 Elements
flags=flags, #
criteria=(cv2.TERM_CRITERIA_EPS & cv2.TERM_CRITERIA_COUNT, 10000, 1e-9))
The camera matrix
usually contains:
cameraMatrix = np.array([[ f, 0., imageSize[0]/2 ],
[ 0. f, imageSize[1]/2 ],
[ 0. 0. 1])
The both parameters cx
and cy
can be found with this equation imageSize[0]/2 for cx
and imageSize[1]/2 for cy
.
I don't know how to calculate the focal length
.
I fond something like this, for the focal length
:
f = imsize[0] / (2 * np.tan(np.deg2rad(hfov/2)))
Edmund Scientics offered the following equation: f = (h.WD/Horizontal FOV)
Is this the right way to create this both parameters the distortion coefficients
and the camera matrix
?
Thanks!