Commit 08c619ff authored by Guillaume CLIVAZ's avatar Guillaume CLIVAZ
Browse files

[calibration] Calibration for all pair of camera + update visualization

parent a78dbbb0
Pipeline #50611 failed with stage
in 3 minutes and 59 seconds
......@@ -48,6 +48,8 @@ def detect_charuco_corners(image, prep_im, charuco_board, verbosity):
"""
"""
corners, ids = None, None
image = np.flip(image, 0)
prep_im = np.flip(prep_im, 0)
if prep_im is None:
markers, ids, rejected_points = cv2.aruco.detectMarkers(image, charuco_board.dictionary)
else:
......@@ -235,8 +237,8 @@ def detect_patterns(directory_path, data_config_path,
.format(capture_name, stream.name))
elif pattern_type == "charuco":
image = np.flip(image, 0)
prep_image = np.flip(prep_image, 0)
#image = np.flip(image, 0)
#prep_image = np.flip(prep_image, 0)
ret , ptrn_pts, ids = detect_charuco_corners(image, prep_image, charuco_board, verbosity)
if ids is not None:
capture_dict[stream.name][capture_name] = (ids, ptrn_pts)
......@@ -433,8 +435,11 @@ def main():
print("Camera matrix \n {} \n Distortion coeffs \n {} \n".format(cam_mat, dist_coefs))
print("Reprojection error \n {}\n".format(err))
if not intrinsics_only:
for camera_2 in stream[idx+1:]:
if not intrinsics_only:
for idx, camera in enumerate(stream):
for camera_2 in stream:
if camera_2 == camera:
continue
df_extrinsics = get_valid_frames_for_extrinsic_calibration(pts, camera, camera_2, pattern_type)
calibration[camera]["df_extrinsics_{}".format(camera_2)] = df_extrinsics
if verbosity > 1:
......@@ -447,7 +452,10 @@ def main():
stream = [k for k, v in calibration.items() if v is not None]
for idx, camera in enumerate(stream):
image_size = image_data[camera]
for camera_2 in stream[idx+1:]:# or with itertools.tee()
for camera_2 in stream:# or with itertools.tee()
if camera_2 == camera:
continue
if image_data[camera_2] != image_size:
raise ValueError("Image size between {} and {} does not match.".format(camera, camera_2))
if not "df_extrinsics_{}".format(camera_2) in calibration[camera].keys():
......@@ -477,16 +485,6 @@ def main():
print("Rotation \n {} \nTranslation \n {} \n".format(R, T.T))
print("Reprojection error \n {}\n".format(err))
# Visualize with color as reference
poses = {}
reference = "left"
for camera in stream:
if camera ==reference:
poses[reference] = np.eye(4)
else:
poses[camera] = calibration[reference]["extrinsics_{}".format(camera)]
display_cameras_poses(poses, config['display'])
if args.output_file is not None:
data = {}
for camera in stream:
......@@ -496,5 +494,16 @@ def main():
json.dump(data, f, indent=4, sort_keys=True)
print("{} written.".format(args.output_file))
for reference in config["display"]["references"]:
poses = {}
#reference = "left"
for camera in stream:
if camera ==reference:
poses[reference] = np.eye(4)
else:
poses[camera] = calibration[reference]["extrinsics_{}".format(camera)]
display_cameras_poses(poses, config['display'])
if __name__ == "__main__":
main()
......@@ -47,6 +47,7 @@
},
"display":
{
"references" : ["left"],
"axe_x" : [-25, 25],
"axe_y" : [-25, 25],
"axe_z" : [-10, 10]
......
......@@ -48,6 +48,7 @@
},
"display":
{
"references" : ["color", "nir_left", "nir_right"],
"axe_x" : [-25, 25],
"axe_y" : [-25, 25],
"axe_z" : [-10, 10]
......
......@@ -38,6 +38,7 @@
},
"display":
{
"references" : ["color", "nir_left", "nir_right"],
"axe_x" : [-25, 25],
"axe_y" : [-25, 25],
"axe_z" : [-10, 10]
......
Supports Markdown
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