Merge branch 'develop' of http://gitlab.mynt.com/mynteye/mynt-eye-sdk-2 into develop
This commit is contained in:
commit
505490697f
|
@ -309,6 +309,7 @@ install(FILES
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/callbacks.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/device.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/types.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/utils.h
|
||||
DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/device
|
||||
)
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include "mynteye/mynteye.h"
|
||||
#include "mynteye/types.h"
|
||||
#include "mynteye/device/callbacks.h"
|
||||
#include "mynteye/device/types.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -51,26 +51,6 @@ class StreamsAdapter;
|
|||
template <class Data>
|
||||
class AsyncCallback;
|
||||
|
||||
namespace device {
|
||||
|
||||
typedef struct ImgParams {
|
||||
bool ok;
|
||||
std::string version;
|
||||
std::shared_ptr<IntrinsicsBase> in_left;
|
||||
std::shared_ptr<IntrinsicsBase> in_right;
|
||||
Extrinsics ex_right_to_left;
|
||||
} img_params_t;
|
||||
|
||||
typedef struct ImuParams {
|
||||
bool ok;
|
||||
std::string version;
|
||||
ImuIntrinsics in_accel;
|
||||
ImuIntrinsics in_gyro;
|
||||
Extrinsics ex_left_to_imu;
|
||||
} imu_params_t;
|
||||
|
||||
} // namespace device
|
||||
|
||||
/**
|
||||
* The Device class to communicate with MYNT® EYE device.
|
||||
*/
|
||||
|
@ -89,6 +69,7 @@ class MYNTEYE_API Device {
|
|||
using motion_async_callback_ptr_t = std::shared_ptr<motion_async_callback_t>;
|
||||
|
||||
using img_params_t = device::img_params_t;
|
||||
using img_params_map_t = std::map<Resolution, img_params_t>;
|
||||
using imu_params_t = device::imu_params_t;
|
||||
|
||||
protected:
|
||||
|
@ -337,10 +318,10 @@ class MYNTEYE_API Device {
|
|||
|
||||
virtual Capabilities GetKeyStreamCapability() const = 0;
|
||||
|
||||
std::map<Resolution, device::img_params_t> GetImgParams() const {
|
||||
img_params_map_t GetImgParams() const {
|
||||
return all_img_params_;
|
||||
}
|
||||
device::imu_params_t GetImuParams() const {
|
||||
imu_params_t GetImuParams() const {
|
||||
return imu_params_;
|
||||
}
|
||||
|
||||
|
@ -352,8 +333,8 @@ class MYNTEYE_API Device {
|
|||
std::shared_ptr<uvc::device> device_;
|
||||
std::shared_ptr<DeviceInfo> device_info_;
|
||||
|
||||
std::map<Resolution, device::img_params_t> all_img_params_;
|
||||
device::imu_params_t imu_params_;
|
||||
img_params_map_t all_img_params_;
|
||||
imu_params_t imu_params_;
|
||||
|
||||
std::map<Stream, std::shared_ptr<IntrinsicsBase>> stream_intrinsics_;
|
||||
std::map<Stream, std::map<Stream, Extrinsics>> stream_from_extrinsics_;
|
||||
|
@ -384,6 +365,11 @@ class MYNTEYE_API Device {
|
|||
void CallbackPushedStreamData(const Stream &stream);
|
||||
void CallbackMotionData(const device::MotionData &data);
|
||||
|
||||
bool GetFiles(
|
||||
DeviceInfo *info, img_params_map_t *img_params, imu_params_t *imu_params);
|
||||
bool SetFiles(
|
||||
DeviceInfo *info, img_params_map_t *img_params, imu_params_t *imu_params);
|
||||
|
||||
friend API;
|
||||
friend tools::DeviceWriter;
|
||||
};
|
||||
|
|
|
@ -18,13 +18,35 @@
|
|||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mynteye/mynteye.h"
|
||||
#include "mynteye/types.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace device {
|
||||
|
||||
typedef struct ImgParams {
|
||||
bool ok;
|
||||
std::string version;
|
||||
std::shared_ptr<IntrinsicsBase> in_left;
|
||||
std::shared_ptr<IntrinsicsBase> in_right;
|
||||
Extrinsics ex_right_to_left;
|
||||
} img_params_t;
|
||||
|
||||
typedef struct ImuParams {
|
||||
bool ok;
|
||||
std::string version;
|
||||
ImuIntrinsics in_accel;
|
||||
ImuIntrinsics in_gyro;
|
||||
Extrinsics ex_left_to_imu;
|
||||
} imu_params_t;
|
||||
|
||||
} // namespace device
|
||||
|
||||
#define MYNTEYE_PROPERTY(TYPE, NAME) \
|
||||
public: \
|
||||
void set_##NAME(TYPE NAME) { \
|
||||
|
@ -142,73 +164,6 @@ struct MYNTEYE_API DeviceInfo {
|
|||
std::uint16_t nominal_baseline;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Imu request packet.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuReqPacket {
|
||||
std::uint8_t header;
|
||||
std::uint32_t serial_number;
|
||||
|
||||
ImuReqPacket() = default;
|
||||
explicit ImuReqPacket(std::uint32_t serial_number)
|
||||
: ImuReqPacket(0x5A, serial_number) {}
|
||||
ImuReqPacket(std::uint8_t header, std::uint32_t serial_number)
|
||||
: header(header), serial_number(serial_number) {}
|
||||
|
||||
std::array<std::uint8_t, 5> to_data() const {
|
||||
return {{header, static_cast<std::uint8_t>((serial_number >> 24) & 0xFF),
|
||||
static_cast<std::uint8_t>((serial_number >> 16) & 0xFF),
|
||||
static_cast<std::uint8_t>((serial_number >> 8) & 0xFF),
|
||||
static_cast<std::uint8_t>(serial_number & 0xFF)}};
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Imu segment.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuSegment {
|
||||
std::uint32_t frame_id;
|
||||
std::uint64_t timestamp;
|
||||
std::uint8_t flag;
|
||||
std::int16_t temperature;
|
||||
std::int16_t accel[3];
|
||||
std::int16_t gyro[3];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Imu packet.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuPacket {
|
||||
std::uint8_t version;
|
||||
std::uint8_t count;
|
||||
std::uint32_t serial_number;
|
||||
std::vector<ImuSegment> segments;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Imu response packet.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuResPacket {
|
||||
std::uint8_t version;
|
||||
std::uint8_t header;
|
||||
std::uint8_t state;
|
||||
std::uint16_t size;
|
||||
std::vector<ImuPacket> packets;
|
||||
std::uint8_t checksum;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#undef MYNTEYE_PROPERTY
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
|
@ -47,6 +47,7 @@ bool DepthProcessor::OnProcess(
|
|||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
int rows = input->value.rows;
|
||||
int cols = input->value.cols;
|
||||
// TODO(MYNTEYE): Put the corresponding parameters(T,f)
|
||||
float T = 0.08;
|
||||
float f = 0.01;
|
||||
cv::Mat depth_mat = cv::Mat::zeros(rows, cols, CV_32F);
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
#define MYNTEYE_DEVICE_CHANNEL_DEF_H_
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "mynteye/mynteye.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
@ -35,6 +39,73 @@ typedef enum FileId {
|
|||
FID_LAST,
|
||||
} file_id_t;
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Imu request packet.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuReqPacket {
|
||||
std::uint8_t header;
|
||||
std::uint32_t serial_number;
|
||||
|
||||
ImuReqPacket() = default;
|
||||
explicit ImuReqPacket(std::uint32_t serial_number)
|
||||
: ImuReqPacket(0x5A, serial_number) {}
|
||||
ImuReqPacket(std::uint8_t header, std::uint32_t serial_number)
|
||||
: header(header), serial_number(serial_number) {}
|
||||
|
||||
std::array<std::uint8_t, 5> to_data() const {
|
||||
return {{header, static_cast<std::uint8_t>((serial_number >> 24) & 0xFF),
|
||||
static_cast<std::uint8_t>((serial_number >> 16) & 0xFF),
|
||||
static_cast<std::uint8_t>((serial_number >> 8) & 0xFF),
|
||||
static_cast<std::uint8_t>(serial_number & 0xFF)}};
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Imu segment.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuSegment {
|
||||
std::uint32_t frame_id;
|
||||
std::uint64_t timestamp;
|
||||
std::uint8_t flag;
|
||||
std::int16_t temperature;
|
||||
std::int16_t accel[3];
|
||||
std::int16_t gyro[3];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Imu packet.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuPacket {
|
||||
std::uint8_t version;
|
||||
std::uint8_t count;
|
||||
std::uint32_t serial_number;
|
||||
std::vector<ImuSegment> segments;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Imu response packet.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuResPacket {
|
||||
std::uint8_t version;
|
||||
std::uint8_t header;
|
||||
std::uint8_t state;
|
||||
std::uint16_t size;
|
||||
std::vector<ImuPacket> packets;
|
||||
std::uint8_t checksum;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_DEVICE_CHANNEL_DEF_H_
|
||||
|
|
|
@ -676,4 +676,14 @@ void Device::CallbackMotionData(const device::MotionData &data) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Device::GetFiles(
|
||||
DeviceInfo *info, img_params_map_t *img_params, imu_params_t *imu_params) {
|
||||
return channels_->GetFiles(info, img_params, imu_params);
|
||||
}
|
||||
|
||||
bool Device::SetFiles(
|
||||
DeviceInfo *info, img_params_map_t *img_params, imu_params_t *imu_params) {
|
||||
return channels_->SetFiles(info, img_params, imu_params);
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
|
|
@ -20,10 +20,6 @@ set_outdir(
|
|||
"${OUT_DIR}/bin/${DIR_NAME}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PRO_DIR}/src
|
||||
)
|
||||
|
||||
## device_writer
|
||||
|
||||
add_library(device_writer STATIC device_writer.cc)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
#include "mynteye/device/device.h"
|
||||
#include "mynteye/util/files.h"
|
||||
|
||||
#define SAVE_LATEST_VERSION Version(1, 2)
|
||||
|
@ -36,15 +35,13 @@ DeviceWriter::~DeviceWriter() {
|
|||
}
|
||||
|
||||
bool DeviceWriter::WriteDeviceInfo(const dev_info_t &info) {
|
||||
auto &&channels = device_->channels();
|
||||
|
||||
// Update device info
|
||||
auto &&dev_info = device_->GetInfo();
|
||||
dev_info->lens_type = Type(info.lens_type);
|
||||
dev_info->imu_type = Type(info.imu_type);
|
||||
dev_info->nominal_baseline = info.nominal_baseline;
|
||||
|
||||
if (channels->SetFiles(dev_info.get(), nullptr, nullptr)) {
|
||||
if (device_->SetFiles(dev_info.get(), nullptr, nullptr)) {
|
||||
LOG(INFO) << "Write device info success";
|
||||
LOG(INFO) << "Device info: {name: " << dev_info->name
|
||||
<< ", serial_number: " << dev_info->serial_number
|
||||
|
@ -68,8 +65,6 @@ bool DeviceWriter::WriteDeviceInfo(const std::string &filepath) {
|
|||
}
|
||||
|
||||
bool DeviceWriter::WriteImgParams(const img_params_map_t &img_params_map) {
|
||||
auto &&channels = device_->channels();
|
||||
|
||||
img_params_map_t *img_params_new =
|
||||
const_cast<img_params_map_t *>(&img_params_map);
|
||||
// Update image params with raw
|
||||
|
@ -81,7 +76,7 @@ bool DeviceWriter::WriteImgParams(const img_params_map_t &img_params_map) {
|
|||
}
|
||||
}
|
||||
|
||||
if (channels->SetFiles(nullptr, img_params_new, nullptr)) {
|
||||
if (device_->SetFiles(nullptr, img_params_new, nullptr)) {
|
||||
LOG(INFO) << "Write img params success";
|
||||
for (auto it = img_params_new->begin(); it != img_params_new->end(); it++) {
|
||||
LOG(INFO) << "Resolution: {width: " << (*it).first.width
|
||||
|
@ -103,8 +98,7 @@ bool DeviceWriter::WriteImgParams(const std::string &filepath) {
|
|||
}
|
||||
|
||||
bool DeviceWriter::WriteImuParams(const imu_params_t ¶ms) {
|
||||
auto &&channels = device_->channels();
|
||||
if (channels->SetFiles(
|
||||
if (device_->SetFiles(
|
||||
nullptr, nullptr, const_cast<imu_params_t *>(¶ms))) {
|
||||
LOG(INFO) << "Write imu params success";
|
||||
LOG(INFO) << "Imu intrinsics accel: {" << params.in_accel << "}";
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "mynteye/mynteye.h"
|
||||
#include "mynteye/device/channel/channels.h"
|
||||
#include "mynteye/device/types.h"
|
||||
#include "mynteye/device/device.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user