2018-05-10 09:46:34 +03:00
|
|
|
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2018-04-03 05:27:28 +03:00
|
|
|
#include "mynteye/types.h"
|
|
|
|
|
2018-04-21 10:45:33 +03:00
|
|
|
#include <iomanip>
|
|
|
|
#include <limits>
|
|
|
|
|
2018-11-16 10:30:13 +02:00
|
|
|
#include "mynteye/logger.h"
|
|
|
|
|
2018-04-21 10:45:33 +03:00
|
|
|
#define FULL_PRECISION \
|
|
|
|
std::fixed << std::setprecision(std::numeric_limits<double>::max_digits10)
|
|
|
|
|
2018-04-03 05:27:28 +03:00
|
|
|
MYNTEYE_BEGIN_NAMESPACE
|
|
|
|
|
2018-04-04 10:52:10 +03:00
|
|
|
const char *to_string(const Model &value) {
|
|
|
|
#define CASE(X) \
|
|
|
|
case Model::X: \
|
|
|
|
return "Model::" #X;
|
|
|
|
switch (value) {
|
|
|
|
CASE(STANDARD)
|
2018-12-20 11:10:18 +02:00
|
|
|
CASE(STANDARD2)
|
2019-01-02 13:41:34 +02:00
|
|
|
CASE(STANDARD210A)
|
2018-04-04 10:52:10 +03:00
|
|
|
default:
|
|
|
|
CHECK(is_valid(value));
|
|
|
|
return "Model::UNKNOWN";
|
|
|
|
}
|
|
|
|
#undef CASE
|
|
|
|
}
|
|
|
|
|
2018-04-03 05:27:28 +03:00
|
|
|
const char *to_string(const Stream &value) {
|
|
|
|
#define CASE(X) \
|
|
|
|
case Stream::X: \
|
|
|
|
return "Stream::" #X;
|
|
|
|
switch (value) {
|
|
|
|
CASE(LEFT)
|
|
|
|
CASE(RIGHT)
|
|
|
|
CASE(LEFT_RECTIFIED)
|
|
|
|
CASE(RIGHT_RECTIFIED)
|
|
|
|
CASE(DISPARITY)
|
|
|
|
CASE(DISPARITY_NORMALIZED)
|
|
|
|
CASE(DEPTH)
|
|
|
|
CASE(POINTS)
|
|
|
|
default:
|
|
|
|
CHECK(is_valid(value));
|
|
|
|
return "Stream::UNKNOWN";
|
|
|
|
}
|
|
|
|
#undef CASE
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *to_string(const Capabilities &value) {
|
|
|
|
#define CASE(X) \
|
|
|
|
case Capabilities::X: \
|
|
|
|
return "Capabilities::" #X;
|
|
|
|
switch (value) {
|
|
|
|
CASE(STEREO)
|
2018-12-20 11:10:18 +02:00
|
|
|
CASE(STEREO_COLOR)
|
2018-04-03 05:27:28 +03:00
|
|
|
CASE(COLOR)
|
|
|
|
CASE(DEPTH)
|
|
|
|
CASE(POINTS)
|
|
|
|
CASE(FISHEYE)
|
2018-04-03 08:53:32 +03:00
|
|
|
CASE(INFRARED)
|
|
|
|
CASE(INFRARED2)
|
2018-04-03 05:27:28 +03:00
|
|
|
CASE(IMU)
|
|
|
|
default:
|
|
|
|
CHECK(is_valid(value));
|
|
|
|
return "Capabilities::UNKNOWN";
|
|
|
|
}
|
|
|
|
#undef CASE
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *to_string(const Info &value) {
|
|
|
|
#define CASE(X) \
|
|
|
|
case Info::X: \
|
|
|
|
return "Info::" #X;
|
|
|
|
switch (value) {
|
|
|
|
CASE(DEVICE_NAME)
|
|
|
|
CASE(SERIAL_NUMBER)
|
|
|
|
CASE(FIRMWARE_VERSION)
|
|
|
|
CASE(HARDWARE_VERSION)
|
|
|
|
CASE(SPEC_VERSION)
|
|
|
|
CASE(LENS_TYPE)
|
|
|
|
CASE(IMU_TYPE)
|
|
|
|
CASE(NOMINAL_BASELINE)
|
|
|
|
default:
|
|
|
|
CHECK(is_valid(value));
|
|
|
|
return "Info::UNKNOWN";
|
|
|
|
}
|
|
|
|
#undef CASE
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *to_string(const Option &value) {
|
|
|
|
#define CASE(X) \
|
|
|
|
case Option::X: \
|
|
|
|
return "Option::" #X;
|
|
|
|
switch (value) {
|
|
|
|
CASE(GAIN)
|
|
|
|
CASE(BRIGHTNESS)
|
|
|
|
CASE(CONTRAST)
|
|
|
|
CASE(FRAME_RATE)
|
|
|
|
CASE(IMU_FREQUENCY)
|
|
|
|
CASE(EXPOSURE_MODE)
|
|
|
|
CASE(MAX_GAIN)
|
|
|
|
CASE(MAX_EXPOSURE_TIME)
|
2018-12-20 11:10:18 +02:00
|
|
|
CASE(MIN_EXPOSURE_TIME)
|
2018-04-03 05:27:28 +03:00
|
|
|
CASE(DESIRED_BRIGHTNESS)
|
|
|
|
CASE(IR_CONTROL)
|
|
|
|
CASE(HDR_MODE)
|
2018-09-14 15:00:28 +03:00
|
|
|
CASE(ACCELEROMETER_RANGE)
|
|
|
|
CASE(GYROSCOPE_RANGE)
|
|
|
|
CASE(ACCELEROMETER_LOW_PASS_FILTER)
|
|
|
|
CASE(GYROSCOPE_LOW_PASS_FILTER)
|
2018-12-20 11:10:18 +02:00
|
|
|
CASE(ZERO_DRIFT_CALIBRATION)
|
|
|
|
CASE(ERASE_CHIP)
|
2018-04-03 05:27:28 +03:00
|
|
|
default:
|
|
|
|
CHECK(is_valid(value));
|
|
|
|
return "Option::UNKNOWN";
|
|
|
|
}
|
|
|
|
#undef CASE
|
|
|
|
}
|
|
|
|
|
2018-04-07 04:36:41 +03:00
|
|
|
const char *to_string(const Source &value) {
|
|
|
|
#define CASE(X) \
|
|
|
|
case Source::X: \
|
|
|
|
return "Source::" #X;
|
|
|
|
switch (value) {
|
|
|
|
CASE(VIDEO_STREAMING)
|
|
|
|
CASE(MOTION_TRACKING)
|
|
|
|
CASE(ALL)
|
|
|
|
default:
|
|
|
|
return "Source::UNKNOWN";
|
|
|
|
}
|
|
|
|
#undef CASE
|
|
|
|
}
|
|
|
|
|
2018-05-04 08:44:13 +03:00
|
|
|
const char *to_string(const AddOns &value) {
|
|
|
|
#define CASE(X) \
|
|
|
|
case AddOns::X: \
|
|
|
|
return "AddOns::" #X;
|
|
|
|
switch (value) {
|
|
|
|
CASE(INFRARED)
|
|
|
|
CASE(INFRARED2)
|
|
|
|
default:
|
|
|
|
return "AddOns::UNKNOWN";
|
|
|
|
}
|
|
|
|
#undef CASE
|
|
|
|
}
|
|
|
|
|
2018-04-06 04:12:09 +03:00
|
|
|
const char *to_string(const Format &value) {
|
|
|
|
#define CASE(X) \
|
|
|
|
case Format::X: \
|
|
|
|
return "Format::" #X;
|
|
|
|
switch (value) {
|
2018-04-08 17:35:49 +03:00
|
|
|
CASE(GREY)
|
2018-04-06 04:12:09 +03:00
|
|
|
CASE(YUYV)
|
2018-12-20 11:10:18 +02:00
|
|
|
CASE(BGR888)
|
2018-04-06 04:12:09 +03:00
|
|
|
default:
|
|
|
|
return "Format::UNKNOWN";
|
|
|
|
}
|
|
|
|
#undef CASE
|
|
|
|
}
|
|
|
|
|
2018-04-08 07:23:33 +03:00
|
|
|
std::size_t bytes_per_pixel(const Format &value) {
|
|
|
|
switch (value) {
|
2018-04-08 17:35:49 +03:00
|
|
|
case Format::GREY:
|
|
|
|
return 1;
|
2018-04-08 07:23:33 +03:00
|
|
|
case Format::YUYV:
|
|
|
|
return 2;
|
2018-08-06 21:29:07 +03:00
|
|
|
case Format::BGR888:
|
2018-08-05 21:23:27 +03:00
|
|
|
return 3;
|
2018-04-08 07:23:33 +03:00
|
|
|
default:
|
|
|
|
LOG(FATAL) << "Unknown format";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-08 17:35:49 +03:00
|
|
|
std::ostream &operator<<(std::ostream &os, const StreamRequest &request) {
|
|
|
|
return os << "width: " << request.width << ", height: " << request.height
|
|
|
|
<< ", format: " << request.format << ", fps: " << request.fps;
|
|
|
|
}
|
|
|
|
|
2019-01-04 05:42:24 +02:00
|
|
|
std::ostream &operator<<(std::ostream &os, const IntrinsicsPinhole &in) {
|
|
|
|
os << "pinhole, " << FULL_PRECISION
|
|
|
|
<< "width: " << in.width << ", height: " << in.height
|
2018-04-21 10:45:33 +03:00
|
|
|
<< ", fx: " << in.fx << ", fy: " << in.fy << ", cx: " << in.cx
|
|
|
|
<< ", cy: " << in.cy << ", model: " << static_cast<int>(in.model)
|
|
|
|
<< ", coeffs: [";
|
2018-04-19 12:23:02 +03:00
|
|
|
for (int i = 0; i <= 3; i++)
|
|
|
|
os << in.coeffs[i] << ", ";
|
|
|
|
return os << in.coeffs[4] << "]";
|
|
|
|
}
|
2019-01-04 09:50:47 +02:00
|
|
|
|
2019-01-04 05:42:24 +02:00
|
|
|
std::ostream &operator<<(std::ostream &os, const IntrinsicsEquidistant &in) {
|
|
|
|
os << "equidistant, " << FULL_PRECISION
|
|
|
|
<< "width: " << in.width << ", height: " << in.height
|
2019-01-04 09:09:21 +02:00
|
|
|
<< ", k2: " << in.coeffs[0] << ", k3: " << in.coeffs[1]
|
|
|
|
<< ", k4: " << in.coeffs[2] << ", k5: " << in.coeffs[3]
|
|
|
|
<< ", mu: " << in.coeffs[4] << ", mv: " << in.coeffs[5]
|
|
|
|
<< ", u0: " << in.coeffs[6] << ", v0: " << in.coeffs[7];
|
2019-01-04 05:42:24 +02:00
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2018-04-19 17:44:40 +03:00
|
|
|
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in) {
|
2018-04-21 10:45:33 +03:00
|
|
|
os << FULL_PRECISION << "scale: [";
|
2018-04-19 12:23:02 +03:00
|
|
|
for (int i = 0; i <= 2; i++)
|
|
|
|
os << in.scale[0][i] << ", ";
|
|
|
|
for (int i = 0; i <= 2; i++)
|
|
|
|
os << in.scale[1][i] << ", ";
|
|
|
|
for (int i = 0; i <= 1; i++)
|
|
|
|
os << in.scale[2][i] << ", ";
|
|
|
|
os << in.scale[2][2] << "]";
|
|
|
|
|
|
|
|
os << ", drift: [";
|
|
|
|
for (int i = 0; i <= 1; i++)
|
|
|
|
os << in.drift[i] << ", ";
|
|
|
|
os << in.drift[2] << "]";
|
|
|
|
|
|
|
|
os << ", noise: [";
|
|
|
|
for (int i = 0; i <= 1; i++)
|
|
|
|
os << in.noise[i] << ", ";
|
|
|
|
os << in.noise[2] << "]";
|
|
|
|
|
|
|
|
os << ", bias: [";
|
|
|
|
for (int i = 0; i <= 1; i++)
|
|
|
|
os << in.bias[i] << ", ";
|
|
|
|
os << in.bias[2] << "]";
|
|
|
|
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2018-04-19 17:44:40 +03:00
|
|
|
std::ostream &operator<<(std::ostream &os, const MotionIntrinsics &in) {
|
2018-04-21 10:45:33 +03:00
|
|
|
return os << FULL_PRECISION << "accel: {" << in.accel << "}, gyro: {"
|
|
|
|
<< in.gyro << "}";
|
2018-04-19 12:23:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream &operator<<(std::ostream &os, const Extrinsics &ex) {
|
2018-04-21 10:45:33 +03:00
|
|
|
os << FULL_PRECISION << "rotation: [";
|
2018-04-19 12:23:02 +03:00
|
|
|
for (int i = 0; i <= 2; i++)
|
|
|
|
os << ex.rotation[0][i] << ", ";
|
|
|
|
for (int i = 0; i <= 2; i++)
|
|
|
|
os << ex.rotation[1][i] << ", ";
|
|
|
|
for (int i = 0; i <= 1; i++)
|
|
|
|
os << ex.rotation[2][i] << ", ";
|
|
|
|
os << ex.rotation[2][2] << "]";
|
|
|
|
|
|
|
|
os << ", translation: [";
|
|
|
|
for (int i = 0; i <= 1; i++)
|
|
|
|
os << ex.translation[i] << ", ";
|
|
|
|
os << ex.translation[2] << "]";
|
|
|
|
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2018-05-04 10:57:12 +03:00
|
|
|
std::ostream &operator<<(std::ostream &os, const OptionInfo &info) {
|
|
|
|
return os << "min: " << info.min << ", max: " << info.max
|
|
|
|
<< ", def: " << info.def;
|
|
|
|
}
|
|
|
|
|
2018-04-03 05:27:28 +03:00
|
|
|
MYNTEYE_END_NAMESPACE
|