38 #ifndef WIN32_LEAN_AND_MEAN 39 #define WIN32_LEAN_AND_MEAN 1 50 #include <sys/types.h> 65 void usage(
const char *programNameP)
68 "USAGE: %s -f <rectified_focal_length> [<options>]\n",
70 fprintf(stderr,
"Where <options> are:\n");
71 fprintf(stderr,
"\t-a <ip_address> : ip address (default=10.66.171.21)\n");
72 fprintf(stderr,
"\t-s : set the rectified focal length (default is query)\n");
83 std::string ipAddress =
"10.66.171.21";
84 double rectifiedFocalLength = -1.0;
86 bool hasAuxCamera =
false;
87 double currentFocalLength = 0.0;
97 while(-1 != (c =
getopt(argc, argvPP,
"a:f:s")))
99 case 'a': ipAddress = std::string(
optarg);
break;
100 case 'f': rectifiedFocalLength = atof(
optarg);
break;
101 case 's':
set =
true;
break;
102 default:
usage(*argvPP);
break;
109 if (rectifiedFocalLength < 200.0) {
110 fprintf(stderr,
"Invalid rectified focal length\n");
118 if (NULL == channelP) {
119 fprintf(stderr,
"Failed to establish communications with \"%s\"\n",
133 fprintf(stderr,
"Failed to query device info: %s\n",
146 fprintf(stderr,
"failed to query image calibration: %s\n",
151 currentFocalLength = calibration.
left.
P[0][0];
152 fprintf(stdout,
"updating focal length from %f to %f\n",
153 currentFocalLength, rectifiedFocalLength);
157 tx = calibration.
right.
P[0][3] / calibration.
right.
P[0][0];
159 calibration.
left.
P[0][0] =
static_cast<float> (rectifiedFocalLength);
160 calibration.
left.
P[1][1] =
static_cast<float> (rectifiedFocalLength);
161 calibration.
right.
P[0][0] =
static_cast<float> (rectifiedFocalLength);
162 calibration.
right.
P[1][1] =
static_cast<float> (rectifiedFocalLength);
163 calibration.
right.
P[0][3] =
static_cast<float> (rectifiedFocalLength * tx);
167 auxTx = calibration.
aux.
P[0][3] / calibration.
aux.
P[0][0];
168 auxTy = calibration.
aux.
P[1][3] / calibration.
aux.
P[1][1];
170 calibration.
aux.
P[0][0] =
static_cast<float> (rectifiedFocalLength);
171 calibration.
aux.
P[1][1] =
static_cast<float> (rectifiedFocalLength);
172 calibration.
aux.
P[0][3] =
static_cast<float> (rectifiedFocalLength * auxTx);
173 calibration.
aux.
P[1][3] =
static_cast<float> (rectifiedFocalLength * auxTy);
178 fprintf(stderr,
"failed to set image calibration: %s\n",
183 fprintf(stdout,
"Rectified focal length successfully updated to %f\n",
184 rectifiedFocalLength);
187 fprintf(stdout,
"Please specify -s to update the rectified focal length to %f\n",
188 rectifiedFocalLength);
static const char * statusString(Status status)
static Channel * Create(const std::string &sensorAddress)
int getopt(int argc, char **argv, char *opts)
virtual Status getImageCalibration(image::Calibration &c)=0
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_MONOCAM
uint32_t hardwareRevision
static CRL_CONSTEXPR Status Status_Ok
int main(int argc, char **argvPP)
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S30
virtual Status setImageCalibration(const image::Calibration &c)=0
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_C6S2_S27
virtual Status getDeviceInfo(system::DeviceInfo &info)=0
static void Destroy(Channel *instanceP)