MYNT-EYE-S-SDK/include/mynteye/types.h

788 lines
18 KiB
C
Raw Normal View History

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-10-27 16:24:04 +03:00
#ifndef MYNTEYE_TYPES_H_
2018-04-03 05:27:28 +03:00
#define MYNTEYE_TYPES_H_
#pragma once
2019-01-04 03:55:30 +02:00
#include <memory.h>
2019-03-26 07:58:20 +02:00
#include <string>
2019-01-04 03:55:30 +02:00
2018-04-03 05:27:28 +03:00
#include <cstdint>
2018-04-08 17:35:49 +03:00
#include <algorithm>
2018-04-03 05:27:28 +03:00
#include <iostream>
#include <type_traits>
#include "mynteye/mynteye.h"
MYNTEYE_BEGIN_NAMESPACE
2018-04-03 18:27:17 +03:00
/**
* @defgroup enumerations Enumerations
* @brief Public enumeration types.
*/
2018-04-04 10:52:10 +03:00
/**
* @ingroup enumerations
* @brief Device model.
*/
enum class Model : std::uint8_t {
/** Standard */
STANDARD,
2019-01-02 13:41:34 +02:00
/** Standard 2 */
STANDARD2,
2019-01-02 13:41:34 +02:00
/** Standard 210a */
STANDARD210A,
2019-08-07 13:42:37 +03:00
/** Standard 200b */
STANDARD200B,
2018-04-04 10:52:10 +03:00
/** Last guard */
LAST
};
2018-04-03 05:27:28 +03:00
/**
* @ingroup enumerations
* @brief Streams define different type of data.
*/
enum class Stream : std::uint8_t {
/** Left stream */
LEFT,
/** Right stream */
RIGHT,
/** Left stream, rectified */
LEFT_RECTIFIED,
/** Right stream, rectified */
RIGHT_RECTIFIED,
/** Disparity stream */
DISPARITY,
/** Disparity stream, normalized */
DISPARITY_NORMALIZED,
/** Depth stream */
DEPTH,
/** Point cloud stream */
POINTS,
/** Last guard */
LAST
};
/**
* @ingroup enumerations
* @brief Capabilities define the full set of functionality that the device
* might provide.
*/
enum class Capabilities : std::uint8_t {
2018-05-16 05:31:31 +03:00
/** Provides stereo stream */
2018-04-03 05:27:28 +03:00
STEREO,
/** Provide stereo color stream */
STEREO_COLOR,
2018-05-16 05:31:31 +03:00
/** Provides color stream */
2018-04-03 05:27:28 +03:00
COLOR,
2018-05-16 05:31:31 +03:00
/** Provides depth stream */
2018-04-03 05:27:28 +03:00
DEPTH,
2018-05-16 05:31:31 +03:00
/** Provides point cloud stream */
2018-04-03 05:27:28 +03:00
POINTS,
2018-05-16 05:31:31 +03:00
/** Provides fisheye stream */
2018-04-03 05:27:28 +03:00
FISHEYE,
2018-05-16 05:31:31 +03:00
/** Provides infrared stream */
2018-04-03 08:53:32 +03:00
INFRARED,
2018-05-16 05:31:31 +03:00
/** Provides second infrared stream */
2018-04-03 08:53:32 +03:00
INFRARED2,
2018-05-16 05:31:31 +03:00
/** Provides IMU (accelerometer, gyroscope) data */
2018-04-03 05:27:28 +03:00
IMU,
/** Last guard */
LAST
};
/**
* @ingroup enumerations
* @brief Camera info fields are read-only strings that can be queried from the
* device.
*/
enum class Info : std::uint8_t {
/** Device name */
DEVICE_NAME,
/** Serial number */
SERIAL_NUMBER,
/** Firmware version */
FIRMWARE_VERSION,
/** Hardware version */
HARDWARE_VERSION,
/** Spec version */
SPEC_VERSION,
/** Lens type */
LENS_TYPE,
/** IMU type */
IMU_TYPE,
/** Nominal baseline */
NOMINAL_BASELINE,
/** Auxiliary chip version */
AUXILIARY_CHIP_VERSION,
/** Isp version */
ISP_VERSION,
2018-04-03 05:27:28 +03:00
/** Last guard */
2018-04-06 04:12:09 +03:00
LAST
2018-04-03 05:27:28 +03:00
};
/**
* @ingroup enumerations
2018-04-03 18:27:17 +03:00
* @brief Camera control options define general configuration controls.
2018-04-03 05:27:28 +03:00
*/
enum class Option : std::uint8_t {
2018-05-16 05:31:31 +03:00
/**
* Image gain, valid if manual-exposure
2019-03-11 07:27:49 +02:00
* <p>
2018-05-16 05:31:31 +03:00
* range: [0,48], default: 24
2019-03-11 07:27:49 +02:00
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
GAIN,
2018-05-16 05:31:31 +03:00
/**
* Image brightness, valid if manual-exposure
2019-03-11 07:27:49 +02:00
* <p>
2018-05-16 05:31:31 +03:00
* range: [0,240], default: 120
2019-03-11 07:27:49 +02:00
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
BRIGHTNESS,
2018-05-16 05:31:31 +03:00
/**
* Image contrast, valid if manual-exposure
2019-03-11 07:27:49 +02:00
* <p>
2019-11-04 10:39:08 +02:00
* range: [0,254], default: 116
2019-03-11 07:27:49 +02:00
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
CONTRAST,
2018-05-16 05:31:31 +03:00
/**
* Image frame rate, must set IMU_FREQUENCY together
2019-03-11 07:27:49 +02:00
* <p>
2018-05-16 05:31:31 +03:00
* values: {10,15,20,25,30,35,40,45,50,55,60}, default: 25
2019-03-11 07:27:49 +02:00
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
FRAME_RATE,
2018-05-16 05:31:31 +03:00
/**
* IMU frequency, must set FRAME_RATE together
2019-03-11 07:27:49 +02:00
* <p>
2018-05-16 05:31:31 +03:00
* values: {100,200,250,333,500}, default: 200
2019-03-11 07:27:49 +02:00
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
IMU_FREQUENCY,
2018-04-03 05:27:28 +03:00
/**
* Exposure mode
2019-03-11 07:27:49 +02:00
* <p>
* 0: enable auto-exposure<br>
2018-04-03 05:27:28 +03:00
* 1: disable auto-exposure (manual-exposure)
2019-03-11 07:27:49 +02:00
* </p>
2018-04-03 05:27:28 +03:00
*/
EXPOSURE_MODE,
2018-05-16 05:31:31 +03:00
/**
* Max gain, valid if auto-exposure
2019-03-11 07:27:49 +02:00
* <p>
* range of standard 1: [0,48], default: 48<br>
* range of standard 2: [0,255], default: 8
2019-03-11 07:27:49 +02:00
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
MAX_GAIN,
2018-05-16 05:31:31 +03:00
/**
* Max exposure time, valid if auto-exposure
2019-03-11 07:27:49 +02:00
* <p>
* range of standard 1: [0,240], default: 240<br>
* range of standard 2: [0,655], default: 333
2019-03-11 07:27:49 +02:00
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
MAX_EXPOSURE_TIME,
/**
* min exposure time, valid if auto-exposure
2019-03-11 07:27:49 +02:00
* <p>
* range: [0,655], default: 0<br>
2019-03-11 07:27:49 +02:00
* </p>
*/
MIN_EXPOSURE_TIME,
2018-05-16 05:31:31 +03:00
/**
* Desired brightness, valid if auto-exposure
2019-03-11 07:27:49 +02:00
* <p>
* range of standard 1: [0,255], default: 192<br>
* range of standard 2: [1,255], default: 122
2019-03-11 07:27:49 +02:00
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
DESIRED_BRIGHTNESS,
2018-05-16 05:31:31 +03:00
/**
* IR control
2019-03-11 07:27:49 +02:00
* <p>
* range: [0,160], default: 0<br>
* </p>
2018-05-16 05:31:31 +03:00
*/
2018-04-03 05:27:28 +03:00
IR_CONTROL,
/**
* HDR mode
2019-03-11 07:27:49 +02:00
* <p>
* 0: normal<br>
* 1: WDR
2019-03-11 07:27:49 +02:00
* </p>
2018-04-03 05:27:28 +03:00
*/
HDR_MODE,
2018-08-16 14:34:01 +03:00
/**
* The range of accelerometer
2019-03-11 07:27:49 +02:00
* <p>
* value of standard 1: {4,8,16,32}, default: 8<br>
* value of standard 2: {6,12,24,48}, default: 12
2019-03-11 07:27:49 +02:00
* </p>
2018-08-16 14:34:01 +03:00
*/
ACCELEROMETER_RANGE,
/**
* The range of gyroscope
2019-03-11 07:27:49 +02:00
* <p>
* value of standard 1: {500,1000,2000,4000}, default: 1000<br>
* value of standard 2: {250,500,1000,2000,4000}, default: 1000
2019-03-11 07:27:49 +02:00
* </p>
2018-08-16 14:34:01 +03:00
*/
GYROSCOPE_RANGE,
/**
* The parameter of accelerometer low pass filter
2019-03-11 07:27:49 +02:00
* <p>
2018-11-20 13:13:41 +02:00
* values: {0,1,2}, default: 2
2019-03-11 07:27:49 +02:00
* </p>
2018-08-16 14:34:01 +03:00
*/
ACCELEROMETER_LOW_PASS_FILTER,
/**
* The parameter of gyroscope low pass filter
2019-03-11 07:27:49 +02:00
* <p>
2018-11-20 13:13:41 +02:00
* values: {23,64}, default: 64
2019-03-11 07:27:49 +02:00
* </p>
2018-08-16 14:34:01 +03:00
*/
GYROSCOPE_LOW_PASS_FILTER,
/**
* The setting of IIC address
* <p>
* range: [0,127], default: 0
* </p>
*/
IIC_ADDRESS_SETTING,
/** Zero drift calibration */
ZERO_DRIFT_CALIBRATION,
/** Erase chip */
ERASE_CHIP,
2019-08-07 13:42:37 +03:00
/** Sync timestamp */
SYNC_TIMESTAMP,
2018-04-03 05:27:28 +03:00
/** Last guard */
2018-04-06 04:12:09 +03:00
LAST
2018-04-03 05:27:28 +03:00
};
2018-04-07 04:36:41 +03:00
/**
* @ingroup enumerations
* @brief Source allows the user to choose which data to be captured.
*/
enum class Source : std::uint8_t {
/** Video streaming of stereo, color, depth, etc. */
VIDEO_STREAMING,
/** Motion tracking of IMU (accelerometer, gyroscope) */
MOTION_TRACKING,
/** Enable everything together */
ALL,
/** Last guard */
LAST
};
2018-05-04 08:44:13 +03:00
/**
* @ingroup enumerations
* @brief Add-Ons are peripheral modules of our hardware.
*/
enum class AddOns : std::uint8_t {
/** Infrared */
INFRARED,
/** Second infrared */
INFRARED2,
/** Last guard */
LAST
};
2018-04-03 05:27:28 +03:00
#define MYNTEYE_ENUM_HELPERS(TYPE) \
2018-04-23 18:11:11 +03:00
MYNTEYE_API const char *to_string(const TYPE &value); \
2018-04-03 05:27:28 +03:00
inline bool is_valid(const TYPE &value) { \
using utype = std::underlying_type<TYPE>::type; \
utype val = static_cast<utype>(value); \
utype max = static_cast<utype>(TYPE::LAST); \
return /*val >= 0 &&*/ val < max; \
} \
inline std::ostream &operator<<(std::ostream &os, const TYPE &value) { \
using utype = std::underlying_type<TYPE>::type; \
if (is_valid(value)) \
return os << to_string(value); \
else \
return os << static_cast<utype>(value); \
}
2018-04-04 10:52:10 +03:00
MYNTEYE_ENUM_HELPERS(Model)
2018-04-03 05:27:28 +03:00
MYNTEYE_ENUM_HELPERS(Stream)
MYNTEYE_ENUM_HELPERS(Capabilities)
MYNTEYE_ENUM_HELPERS(Info)
MYNTEYE_ENUM_HELPERS(Option)
2018-04-07 04:36:41 +03:00
MYNTEYE_ENUM_HELPERS(Source)
2018-05-04 08:44:13 +03:00
MYNTEYE_ENUM_HELPERS(AddOns)
2018-04-03 05:27:28 +03:00
#undef MYNTEYE_ENUM_HELPERS
2018-04-06 04:12:09 +03:00
#define MYNTEYE_FOURCC(a, b, c, d) \
((std::uint32_t)(a) | ((std::uint32_t)(b) << 8) | \
((std::uint32_t)(c) << 16) | ((std::uint32_t)(d) << 24)) // NOLINT
/**
* @ingroup enumerations
* @brief Formats define how each stream can be encoded.
*/
enum class Format : std::uint32_t {
2018-04-08 17:35:49 +03:00
/** Greyscale, 8 bits per pixel */
GREY = MYNTEYE_FOURCC('G', 'R', 'E', 'Y'),
2018-04-06 04:12:09 +03:00
/** YUV 4:2:2, 16 bits per pixel */
YUYV = MYNTEYE_FOURCC('Y', 'U', 'Y', 'V'),
2018-08-06 21:29:07 +03:00
/** BGR 8:8:8, 24 bits per pixel */
BGR888 = MYNTEYE_FOURCC('B', 'G', 'R', '3'),
2019-01-02 13:41:34 +02:00
/** RGB 8:8:8, 24 bits per pixel */
RGB888 = MYNTEYE_FOURCC('R', 'G', 'B', '3'),
2018-04-06 04:12:09 +03:00
/** Last guard */
LAST
};
#undef MYNTEYE_FOURCC
2019-03-15 13:46:20 +02:00
/**
* @ingroup enumerations
* @brief Process modes.
*/
enum class ProcessMode : std::int32_t {
PROC_NONE = 0,
PROC_IMU_ASSEMBLY = 1,
PROC_IMU_TEMP_DRIFT = 2,
PROC_IMU_ALL = PROC_IMU_ASSEMBLY | PROC_IMU_TEMP_DRIFT
};
inline
std::int32_t operator&(const std::int32_t& lhs, const ProcessMode& rhs) {
return lhs & static_cast<std::int32_t>(rhs);
}
inline
std::int32_t operator&(const ProcessMode& lhs, const std::int32_t& rhs) {
return static_cast<std::int32_t>(lhs) & rhs;
}
inline
std::int32_t operator&(const ProcessMode& lhs, const ProcessMode& rhs) {
return static_cast<std::int32_t>(lhs) & static_cast<std::int32_t>(rhs);
}
2018-04-23 18:11:11 +03:00
MYNTEYE_API const char *to_string(const Format &value);
2018-04-06 04:12:09 +03:00
inline std::ostream &operator<<(std::ostream &os, const Format &value) {
return os << to_string(value);
}
2018-04-23 18:11:11 +03:00
MYNTEYE_API std::size_t bytes_per_pixel(const Format &value);
2018-04-08 07:23:33 +03:00
/**
* Resolution.
*/
struct MYNTEYE_API Resolution {
/** Width */
std::uint16_t width;
/** Height */
std::uint16_t height;
bool operator==(const Resolution &other) const {
return width == other.width && height == other.height;
}
bool operator!=(const Resolution &other) const {
return !(*this == other);
}
bool operator<(const Resolution &other) const {
return (width * height) < (other.width * other.height);
}
};
2018-04-06 04:12:09 +03:00
/**
* Stream request.
*/
struct MYNTEYE_API StreamRequest {
2018-05-16 05:31:31 +03:00
/** Stream width in pixels */
2018-04-06 04:12:09 +03:00
std::uint16_t width;
2018-05-16 05:31:31 +03:00
/** Stream height in pixels */
2018-04-06 04:12:09 +03:00
std::uint16_t height;
2018-05-16 05:31:31 +03:00
/** Stream pixel format */
2018-04-06 04:12:09 +03:00
Format format;
/** Stream frames per second */
2018-04-06 04:12:09 +03:00
std::uint16_t fps;
2018-04-08 07:23:33 +03:00
StreamRequest() {}
StreamRequest(
std::uint16_t width, std::uint16_t height, Format format,
std::uint16_t fps)
: width(width), height(height), format(format), fps(fps) {}
StreamRequest(const Resolution &res, Format format, std::uint16_t fps)
: width(res.width), height(res.height), format(format), fps(fps) {}
Resolution GetResolution() const { return {width, height}; }
2018-04-08 07:23:33 +03:00
bool operator==(const StreamRequest &other) const {
return width == other.width && height == other.height &&
format == other.format && fps == other.fps;
}
bool operator!=(const StreamRequest &other) const {
return !(*this == other);
}
2018-04-06 04:12:09 +03:00
};
2018-04-23 18:11:11 +03:00
MYNTEYE_API
2018-04-08 17:35:49 +03:00
std::ostream &operator<<(std::ostream &os, const StreamRequest &request);
2018-04-03 18:27:17 +03:00
/**
* @defgroup calibration Intrinsics & Extrinsics
* @brief Intrinsic and extrinsic properties.
*/
/**
* @ingroup calibration
* Camera calibration model.
2018-04-03 18:27:17 +03:00
*/
enum class CalibrationModel : std::uint8_t {
/** Pinhole */
PINHOLE = 0,
/** Equidistant: KANNALA_BRANDT */
KANNALA_BRANDT = 1,
/** Unknow */
UNKNOW
};
MYNTEYE_API const char *to_string(const CalibrationModel &model);
inline std::ostream &operator<<(std::ostream &os,
const CalibrationModel &model) {
return os << to_string(model);
}
2019-01-04 03:55:30 +02:00
struct MYNTEYE_API IntrinsicsBase {
IntrinsicsBase() {
calib_model_ = CalibrationModel::UNKNOW;
2019-01-04 03:55:30 +02:00
}
virtual ~IntrinsicsBase() {}
2019-03-15 11:10:52 +02:00
virtual void ResizeIntrinsics() {}
/** The calibration model */
CalibrationModel calib_model() const {
return calib_model_;
}
/** The width of the image in pixels */
std::uint16_t width;
/** The height of the image in pixels */
std::uint16_t height;
2019-03-15 11:10:52 +02:00
/** Resize scale */
double resize_scale = 1.0;
protected:
CalibrationModel calib_model_;
2019-01-04 03:55:30 +02:00
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const IntrinsicsBase &in);
/**
* @ingroup calibration
* Stream intrinsics (Pinhole)
*/
struct MYNTEYE_API IntrinsicsPinhole : public IntrinsicsBase {
IntrinsicsPinhole() {
calib_model_ = CalibrationModel::PINHOLE;
2019-01-04 03:55:30 +02:00
}
2019-03-15 11:10:52 +02:00
void ResizeIntrinsics() {
width = static_cast<std::uint16_t>(width * resize_scale);
height = static_cast<std::uint16_t>(height * resize_scale);
fx *= resize_scale;
fy *= resize_scale;
cx *= resize_scale;
cy *= resize_scale;
2019-03-15 14:15:55 +02:00
resize_scale = 1.0;
2019-03-15 11:10:52 +02:00
}
2018-05-16 05:31:31 +03:00
/** The focal length of the image plane, as a multiple of pixel width */
2018-04-03 17:10:25 +03:00
double fx;
2018-05-16 05:31:31 +03:00
/** The focal length of the image plane, as a multiple of pixel height */
2018-04-03 17:10:25 +03:00
double fy;
2018-05-16 05:31:31 +03:00
/** The horizontal coordinate of the principal point of the image */
2018-04-03 17:10:25 +03:00
double cx;
2018-05-16 05:31:31 +03:00
/** The vertical coordinate of the principal point of the image */
2018-04-03 17:10:25 +03:00
double cy;
/** @deprecated Replaced by calib_model_. The distortion model of the image */
2018-04-03 17:10:25 +03:00
std::uint8_t model;
2018-05-16 05:31:31 +03:00
/** The distortion coefficients: k1,k2,p1,p2,k3 */
2018-04-03 17:10:25 +03:00
double coeffs[5];
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const IntrinsicsPinhole &in);
/**
* @deprecated Replaced by IntrinsicsPinhole.
*/
using Intrinsics = IntrinsicsPinhole;
/**
* @ingroup calibration
* Stream intrinsics (Equidistant: KANNALA_BRANDT)
*/
struct MYNTEYE_API IntrinsicsEquidistant : public IntrinsicsBase {
IntrinsicsEquidistant() {
calib_model_ = CalibrationModel::KANNALA_BRANDT;
2019-01-04 03:55:30 +02:00
}
/** The distortion coefficients: k2,k3,k4,k5,mu,mv,u0,v0 */
2019-01-04 09:09:21 +02:00
double coeffs[8];
2019-03-15 11:10:52 +02:00
void ResizeIntrinsics() {
width = static_cast<std::uint16_t>(width * resize_scale);
height = static_cast<std::uint16_t>(height * resize_scale);
coeffs[4] *= resize_scale;
coeffs[5] *= resize_scale;
coeffs[6] *= resize_scale;
coeffs[7] *= resize_scale;
2019-03-15 14:15:55 +02:00
resize_scale = 1.0;
2019-03-15 11:10:52 +02:00
}
2019-01-04 03:55:30 +02:00
};
2018-04-23 18:11:11 +03:00
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const IntrinsicsEquidistant &in);
2018-04-19 12:23:02 +03:00
2018-04-03 18:27:17 +03:00
/**
* @ingroup calibration
* IMU intrinsics: scale, drift and variances.
2018-04-03 18:27:17 +03:00
*/
struct MYNTEYE_API ImuIntrinsics {
2018-04-03 17:10:25 +03:00
/**
2018-05-16 05:31:31 +03:00
* Scale matrix.
* \code
* Scale X cross axis cross axis
* cross axis Scale Y cross axis
* cross axis cross axis Scale Z
* \endcode
2018-04-03 17:10:25 +03:00
*/
double scale[3][3];
/** Assembly error [3][3] */
double assembly[3][3];
2019-10-22 10:00:44 +03:00
/** Zero-drift: X, Y, Z */
2018-04-03 17:10:25 +03:00
double drift[3];
/** Noise density variances */
double noise[3];
/** Random walk variances */
double bias[3];
/** Temperature drift
* \code
* 0 - Constant value
* 1 - Slope
* \endcode
*/
double x[2];
double y[2];
double z[2];
2018-04-03 17:10:25 +03:00
};
2018-04-23 18:11:11 +03:00
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in);
2018-04-19 12:23:02 +03:00
2018-04-03 18:27:17 +03:00
/**
* @ingroup calibration
* Motion intrinsics, including accelerometer and gyroscope.
2018-04-03 18:27:17 +03:00
*/
struct MYNTEYE_API MotionIntrinsics {
2018-05-16 05:31:31 +03:00
ImuIntrinsics accel; /**< Accelerometer intrinsics */
ImuIntrinsics gyro; /**< Gyroscope intrinsics */
2018-04-03 17:10:25 +03:00
};
2018-04-23 18:11:11 +03:00
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const MotionIntrinsics &in);
2018-04-19 12:23:02 +03:00
2018-04-03 17:10:25 +03:00
/**
2018-04-03 18:27:17 +03:00
* @ingroup calibration
2018-04-06 04:12:09 +03:00
* Extrinsics, represent how the different datas are connected.
2018-04-03 17:10:25 +03:00
*/
2018-04-04 04:21:45 +03:00
struct MYNTEYE_API Extrinsics {
2018-05-16 05:31:31 +03:00
double rotation[3][3]; /**< Rotation matrix */
double translation[3]; /**< Translation vector */
2018-04-29 09:47:35 +03:00
2018-05-16 05:31:31 +03:00
/**
* Inverse this extrinsics.
* @return the inversed extrinsics.
*/
2018-04-29 09:47:35 +03:00
Extrinsics Inverse() const {
return {{{rotation[0][0], rotation[1][0], rotation[2][0]},
{rotation[0][1], rotation[1][1], rotation[2][1]},
{rotation[0][2], rotation[1][2], rotation[2][2]}},
{-translation[0], -translation[1], -translation[2]}};
}
2018-04-03 17:10:25 +03:00
};
2018-04-23 18:11:11 +03:00
MYNTEYE_API
2018-04-19 12:23:02 +03:00
std::ostream &operator<<(std::ostream &os, const Extrinsics &ex);
/**
* @defgroup disparity params
*/
/**
* @ingroup disparity
* Camera disparity computing method type.
*/
enum class DisparityComputingMethod : std::uint8_t {
/** bm */
SGBM = 0,
/** sgbm */
BM = 1,
/** unknow */
UNKNOW
};
2018-04-03 18:27:17 +03:00
/**
* @defgroup datatypes Datatypes
* @brief Public data types.
*/
/**
* @ingroup datatypes
* Image data.
*/
2018-04-04 04:21:45 +03:00
struct MYNTEYE_API ImgData {
2018-04-03 17:10:25 +03:00
/** Image frame id */
std::uint16_t frame_id;
2018-10-23 11:08:59 +03:00
/** Image timestamp in 1us */
2018-08-01 17:00:38 +03:00
std::uint64_t timestamp;
2018-05-13 05:34:03 +03:00
/** Image exposure time, virtual value in [1, 480] */
2018-04-03 17:10:25 +03:00
std::uint16_t exposure_time;
/** Is external time source */
2019-03-29 12:28:10 +03:00
bool is_ets = false;
2018-04-08 17:35:49 +03:00
void Reset() {
frame_id = 0;
timestamp = 0;
exposure_time = 0;
2019-03-29 12:28:10 +03:00
is_ets = false;
2018-04-08 17:35:49 +03:00
}
2018-04-08 20:20:00 +03:00
ImgData() {
Reset();
}
ImgData(const ImgData &other) {
frame_id = other.frame_id;
timestamp = other.timestamp;
exposure_time = other.exposure_time;
2019-03-29 12:28:10 +03:00
is_ets = other.is_ets;
2018-04-08 20:20:00 +03:00
}
ImgData &operator=(const ImgData &other) {
frame_id = other.frame_id;
timestamp = other.timestamp;
exposure_time = other.exposure_time;
2019-03-29 12:28:10 +03:00
is_ets = other.is_ets;
2018-04-08 20:20:00 +03:00
return *this;
}
2018-04-03 17:10:25 +03:00
};
2018-04-03 18:27:17 +03:00
/**
* @ingroup datatypes
* IMU data.
*/
2018-04-04 04:21:45 +03:00
struct MYNTEYE_API ImuData {
2018-12-23 14:58:18 +02:00
/** IMU frame id */
2018-12-21 16:04:40 +02:00
std::uint32_t frame_id;
/**
* IMU accel or gyro flag
2019-03-11 07:27:49 +02:00
* <p>
* 0: accel and gyro are both valid<br>
* 1: accel is valid<br>
* 2: gyro is valid
2019-03-11 07:27:49 +02:00
* </p>
*/
2018-07-21 10:34:07 +03:00
std::uint8_t flag;
2019-03-29 12:45:20 +03:00
/** Is external time source */
bool is_ets = false;
2018-08-03 14:31:36 +03:00
/** IMU timestamp in 1us */
2018-07-21 10:34:07 +03:00
std::uint64_t timestamp;
2018-04-03 17:10:25 +03:00
/** IMU accelerometer data for 3-axis: X, Y, Z. */
double accel[3];
/** IMU gyroscope data for 3-axis: X, Y, Z. */
double gyro[3];
/** IMU temperature */
double temperature;
2018-04-08 17:35:49 +03:00
void Reset() {
2018-07-21 10:34:07 +03:00
flag = 0;
2018-04-08 17:35:49 +03:00
timestamp = 0;
std::fill(accel, accel + 3, 0);
std::fill(gyro, gyro + 3, 0);
temperature = 0;
}
2018-04-08 20:20:00 +03:00
ImuData() {
Reset();
}
2018-04-03 17:10:25 +03:00
};
2018-04-09 19:26:22 +03:00
/**
* @ingroup datatypes
* Option info.
*/
struct MYNTEYE_API OptionInfo {
2018-05-16 05:31:31 +03:00
/** Minimum value */
2018-04-09 19:26:22 +03:00
std::int32_t min;
2018-05-16 05:31:31 +03:00
/** Maximum value */
2018-04-09 19:26:22 +03:00
std::int32_t max;
2018-05-16 05:31:31 +03:00
/** Default value */
2018-04-09 19:26:22 +03:00
std::int32_t def;
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const OptionInfo &info);
2019-03-26 07:58:20 +02:00
/**
* @ingroup datatypes
* ROS camera info.
*/
struct MYNTEYE_API CameraROSMsgInfo {
/** height */
unsigned int height = 0;
/** width */
unsigned int width = 0;
/** calib model */
std::string distortion_model = "null";
double D[5] = {0};
double K[9] = {0};
double R[9] = {0};
double P[12] = {0};
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const CameraROSMsgInfo &info);
struct CameraROSMsgInfoPair {
inline bool isEmpty() {
return left.height * left.width * right.height * right.width <= 0;
}
struct CameraROSMsgInfo left;
struct CameraROSMsgInfo right;
double T_mul_f = -1.f;
2019-08-17 13:52:31 +03:00
double cx1_minus_cx2 = 0.f;
2019-03-26 07:58:20 +02:00
double R[9] = {0};
double P[12] = {0};
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const CameraROSMsgInfoPair &info);
2018-04-03 05:27:28 +03:00
MYNTEYE_END_NAMESPACE
2018-10-27 16:24:04 +03:00
#endif // MYNTEYE_TYPES_H_