40 import libmultisense
as lms
43 print(
"Updating focal length from", cal.left.P[0][0],
"to", new_focal_length)
45 cal.left.P[0][0] = new_focal_length
46 cal.left.P[1][1] = new_focal_length
48 right_tx = cal.right.P[0][3] / cal.right.P[0][0]
49 cal.right.P[0][0] = new_focal_length
50 cal.right.P[1][1] = new_focal_length
51 cal.right.P[0][3] = new_focal_length * right_tx
54 aux_tx = cal.aux.P[0][3] / cal.aux.P[0][0]
55 aux_ty = cal.aux.P[1][3] / cal.aux.P[1][1]
57 cal.aux.P[0][0] = new_focal_length
58 cal.aux.P[1][1] = new_focal_length
59 cal.aux.P[0][3] = new_focal_length * aux_tx
60 cal.aux.P[1][3] = new_focal_length * aux_ty
65 channel_config = lms.ChannelConfig()
66 channel_config.ip_address = args.ip_address
67 channel_config.mtu = args.mtu
69 with lms.Channel.create(channel_config)
as channel:
71 print(
"Invalid channel")
74 current_calibration = channel.get_calibration();
79 if channel.set_calibration(new_calibration) != lms.Status.OK:
80 print(
"Failed to set the updated calibration")
83 if __name__ ==
'__main__':
84 parser = argparse.ArgumentParser(
"LibMultiSense save image utility")
85 parser.add_argument(
"-a",
"--ip_address", default=
"10.66.171.21", help=
"The IPv4 address of the MultiSense.")
86 parser.add_argument(
"-m",
"--mtu", type=int, default=1500, help=
"The MTU to use to communicate with the camera.")
87 parser.add_argument(
"-r",
"--rectified-focal-length", type=float, required=
True, help=
"The new rectified focal length")
88 parser.add_argument(
"-s",
"--set", action=
"store_true", help=
"Write the new calibration to camera")
89 main(parser.parse_args())