38 #ifndef WIN32_LEAN_AND_MEAN
39 #define WIN32_LEAN_AND_MEAN 1
50 #include <MultiSense/MultiSenseChannel.hh>
60 void usage(
const char *name)
62 std::cerr <<
"USAGE: " << name <<
" [<options>]" << std::endl;
63 std::cerr <<
"Where <options> are:" << std::endl;
64 std::cerr <<
"\t-a <current_address> : CURRENT IPV4 address (default=10.66.171.21)" << std::endl;
65 std::cerr <<
"\t-m <mtu> : MTU to use to communicate with the camera (default=1500)" << std::endl;
66 std::cerr <<
"\t-r <new-rectified-focal-length> : The new rectified focal length" << std::endl;
67 std::cerr <<
"\t-s : Set the new calibration (Default is query)" << std::endl;
73 std::cout <<
"Updating focal length from " << cal.
left.
P[0][0] <<
" to " << new_focal_length << std::endl;
75 cal.
left.
P[0][0] = new_focal_length;
76 cal.
left.
P[1][1] = new_focal_length;
78 const float right_tx = cal.
right.
P[0][3] / cal.
right.
P[0][0];
79 cal.
right.
P[0][0] = new_focal_length;
80 cal.
right.
P[1][1] = new_focal_length;
81 cal.
right.
P[0][3] = new_focal_length * right_tx;
85 const float aux_tx = cal.
aux->P[0][3] / cal.
aux->P[0][0];
86 const float aux_ty = cal.
aux->P[1][3] / cal.
aux->P[1][1];
88 cal.
aux->P[0][0] = new_focal_length;
89 cal.
aux->P[1][1] = new_focal_length;
90 cal.
aux->P[0][3] = new_focal_length * aux_tx;
91 cal.
aux->P[1][3] = new_focal_length * aux_ty;
99 int main(
int argc,
char** argv)
101 std::string ip_address =
"10.66.171.21";
103 std::optional<float> rectified_focal_length = std::nullopt;
107 while(-1 != (c =
getopt(argc, argv,
"a:m:r:s")))
111 case 'a': ip_address = std::string(
optarg);
break;
112 case 'm': mtu =
static_cast<uint16_t
>(atoi(
optarg));
break;
113 case 'r': rectified_focal_length = std::stof(
optarg);
break;
114 case 's': set =
true;
break;
115 default:
usage(*argv);
break;
119 if (!rectified_focal_length || rectified_focal_length.value() < 0.0)
121 std::cerr <<
"Invalid input rectified focal length" << std::endl;;
128 std::cerr <<
"Failed to create channel" << std::endl;
132 const auto current_calibration = channel->get_calibration();
134 const auto new_calibration =
update_calibration(current_calibration, rectified_focal_length.value());
138 if (channel->set_calibration(new_calibration) != lms::Status::OK)
140 std::cerr <<
"Failed to set the updated calibration" << std::endl;
146 std::cout <<
"Please add the \"-s\" argument to write the new rectified focal length to the camera" << std::endl;