Commit a3c6cdd7 authored by Guillaume CLIVAZ's avatar Guillaume CLIVAZ
Browse files

[calibration] Remove assert checking if image size are equal

* cv2.StereoCalibrate use image size to initialize camera matrix, but it is already give and fixed in this case.
parent 1787311e
......@@ -125,12 +125,13 @@ def compute_intrinsics(im_pts, image_size, obj_pts=None, ids=None, charuco_board
return reprojection_error, cam_mat, dist_coefs
def compute_relative_extrinsics(obj_pts, im_pts1, cam_m1, dist_1, im_pts2, cam_m2, dist_2, image_size):
def compute_relative_extrinsics(obj_pts, im_pts1, cam_m1, dist_1, im_pts2, cam_m2, dist_2, image_size=None):
""" """
R, T, E, F = None, None, None, None
criteria = (cv2.TERM_CRITERIA_MAX_ITER + cv2.TERM_CRITERIA_EPS, 1000, 1e-5)
flags = cv2.CALIB_FIX_INTRINSIC
image_size = (image_size[1], image_size[0])
# In cv2.stereoCalibrate, image_size is used to initialize the intrinsics matrix. As the intrinsics are
# already computed, the flags can be set to cv2.CALIB_FIX_INTRINSIC
(reprojection_error, _, _, _, _, R, T, E, F) = cv2.stereoCalibrate(
obj_pts,
im_pts1,
......@@ -483,8 +484,6 @@ def main():
# if camera_2 == camera:
# continue
if image_data[reference] != image_size:
raise ValueError("Image size between {} and {} does not match.".format(camera, reference))
if not "df_extrinsics_{}".format(reference) in calibration[camera].keys():
continue
df = calibration[camera]["df_extrinsics_{}".format(reference)]
......@@ -500,7 +499,7 @@ def main():
if np.linalg.norm(i1 - i2) != 0.0:
raise ValueError("Difference between both ids")
err, R, T = compute_relative_extrinsics(
obj_pts, im_pts1, cam_mat1, dist_coefs1, im_pts2, cam_mat2, dist_coefs2, image_size
obj_pts, im_pts1, cam_mat1, dist_coefs1, im_pts2, cam_mat2, dist_coefs2
)
H = np.eye(4)
H[0:3, 0:3] = R
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment