Improve intrinsics & extrinsics interfaces
This commit is contained in:
parent
e04a05f6f9
commit
f6120d5ae6
|
@ -248,9 +248,9 @@ std::ostream &operator<<(std::ostream &os, const StreamRequest &request);
|
|||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* Image intrinsics.
|
||||
* Stream intrinsics,
|
||||
*/
|
||||
struct MYNTEYE_API ImgIntrinsics {
|
||||
struct MYNTEYE_API Intrinsics {
|
||||
/** width of the image in pixels */
|
||||
std::uint16_t width;
|
||||
/** height of the image in pixels */
|
||||
|
@ -269,13 +269,13 @@ struct MYNTEYE_API ImgIntrinsics {
|
|||
double coeffs[5];
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImgIntrinsics &in);
|
||||
std::ostream &operator<<(std::ostream &os, const Intrinsics &in);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* IMU sensor intrinsics: scale, drift and variances.
|
||||
* IMU intrinsics: scale, drift and variances.
|
||||
*/
|
||||
struct MYNTEYE_API ImuSensorIntrinsics {
|
||||
struct MYNTEYE_API ImuIntrinsics {
|
||||
/**
|
||||
* Scale X cross axis cross axis
|
||||
* cross axis Scale Y cross axis
|
||||
|
@ -291,18 +291,18 @@ struct MYNTEYE_API ImuSensorIntrinsics {
|
|||
double bias[3];
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImuSensorIntrinsics &in);
|
||||
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* IMU intrinsics, including accelerometer and gyroscope.
|
||||
* Motion intrinsics, including accelerometer and gyroscope.
|
||||
*/
|
||||
struct MYNTEYE_API ImuIntrinsics {
|
||||
ImuSensorIntrinsics accel;
|
||||
ImuSensorIntrinsics gyro;
|
||||
struct MYNTEYE_API MotionIntrinsics {
|
||||
ImuIntrinsics accel;
|
||||
ImuIntrinsics gyro;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in);
|
||||
std::ostream &operator<<(std::ostream &os, const MotionIntrinsics &in);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
|
@ -315,26 +315,6 @@ struct MYNTEYE_API Extrinsics {
|
|||
|
||||
std::ostream &operator<<(std::ostream &os, const Extrinsics &ex);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* Image extrinsics.
|
||||
*/
|
||||
struct MYNTEYE_API ImgExtrinsics {
|
||||
Extrinsics left_to_right;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImgExtrinsics &ex);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* IMU extrinsics.
|
||||
*/
|
||||
struct MYNTEYE_API ImuExtrinsics {
|
||||
Extrinsics left_to_imu;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImuExtrinsics &ex);
|
||||
|
||||
/**
|
||||
* @defgroup datatypes Datatypes
|
||||
* @brief Public data types.
|
||||
|
|
|
@ -151,36 +151,60 @@ std::string Device::GetInfo(const Info &info) const {
|
|||
}
|
||||
}
|
||||
|
||||
ImgIntrinsics Device::GetImgIntrinsics() const {
|
||||
return img_intrinsics_;
|
||||
Intrinsics Device::GetIntrinsics(const Stream &stream) const {
|
||||
try {
|
||||
return stream_intrinsics_.at(stream);
|
||||
} catch (const std::out_of_range &e) {
|
||||
LOG(WARNING) << "Intrinsics of " << stream << " not found";
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
ImgExtrinsics Device::GetImgExtrinsics() const {
|
||||
return img_extrinsics_;
|
||||
Extrinsics Device::GetExtrinsics(const Stream &from, const Stream &to) const {
|
||||
try {
|
||||
return stream_from_extrinsics_.at(from).at(to);
|
||||
} catch (const std::out_of_range &e) {
|
||||
LOG(WARNING) << "Extrinsics from " << from << " to " << to << " not found";
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void Device::SetImgIntrinsics(const ImgIntrinsics &in) {
|
||||
img_intrinsics_ = std::move(in);
|
||||
MotionIntrinsics Device::GetMotionIntrinsics() const {
|
||||
if (motion_intrinsics_) {
|
||||
return *motion_intrinsics_;
|
||||
} else {
|
||||
LOG(WARNING) << "Motion intrinsics not found";
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void Device::SetImgExtrinsics(const ImgExtrinsics &ex) {
|
||||
img_extrinsics_ = std::move(ex);
|
||||
Extrinsics Device::GetMotionExtrinsics(const Stream &from) const {
|
||||
try {
|
||||
return motion_from_extrinsics_.at(from);
|
||||
} catch (const std::out_of_range &e) {
|
||||
LOG(WARNING) << "Motion extrinsics from " << from << " not found";
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
ImuIntrinsics Device::GetImuIntrinsics() const {
|
||||
return imu_intrinsics_;
|
||||
void Device::SetIntrinsics(const Stream &stream, const Intrinsics &in) {
|
||||
stream_intrinsics_[stream] = in;
|
||||
}
|
||||
|
||||
ImuExtrinsics Device::GetImuExtrinsics() const {
|
||||
return imu_extrinsics_;
|
||||
void Device::SetExtrinsics(
|
||||
const Stream &from, const Stream &to, const Extrinsics &ex) {
|
||||
stream_from_extrinsics_[from][to] = ex;
|
||||
}
|
||||
|
||||
void Device::SetImuIntrinsics(const ImuIntrinsics &in) {
|
||||
imu_intrinsics_ = std::move(in);
|
||||
void Device::SetMotionIntrinsics(const MotionIntrinsics &in) {
|
||||
if (motion_intrinsics_ == nullptr) {
|
||||
motion_intrinsics_ = std::make_shared<MotionIntrinsics>();
|
||||
}
|
||||
*motion_intrinsics_ = in;
|
||||
}
|
||||
|
||||
void Device::SetImuExtrinsics(const ImuExtrinsics &ex) {
|
||||
imu_extrinsics_ = std::move(ex);
|
||||
void Device::SetMotionExtrinsics(const Stream &from, const Extrinsics &ex) {
|
||||
motion_from_extrinsics_[from] = ex;
|
||||
}
|
||||
|
||||
void Device::LogOptionInfos() const {
|
||||
|
@ -426,7 +450,7 @@ void Device::ReadAllInfos() {
|
|||
if (!channels_->GetFiles(device_info_.get(), &img_params, &imu_params)) {
|
||||
LOG(FATAL) << "Read device infos failed :(";
|
||||
}
|
||||
VLOG(2) << "Device name: " << device_info_->name
|
||||
VLOG(2) << "Device info: {name: " << device_info_->name
|
||||
<< ", serial_number: " << device_info_->serial_number
|
||||
<< ", firmware_version: "
|
||||
<< device_info_->firmware_version.to_string()
|
||||
|
@ -435,56 +459,28 @@ void Device::ReadAllInfos() {
|
|||
<< ", spec_version: " << device_info_->spec_version.to_string()
|
||||
<< ", lens_type: " << device_info_->lens_type.to_string()
|
||||
<< ", imu_type: " << device_info_->imu_type.to_string()
|
||||
<< ", nominal_baseline: " << device_info_->nominal_baseline;
|
||||
<< ", nominal_baseline: " << device_info_->nominal_baseline << "}";
|
||||
|
||||
device_info_->name = uvc::get_name(*device_);
|
||||
if (img_params.ok) {
|
||||
img_intrinsics_ = img_params.in;
|
||||
img_extrinsics_ = img_params.ex;
|
||||
VLOG(2) << "ImgIntrinsics " << img_intrinsics_;
|
||||
VLOG(2) << "ImgExtrinsics " << img_extrinsics_;
|
||||
SetIntrinsics(Stream::LEFT, img_params.in_left);
|
||||
SetIntrinsics(Stream::RIGHT, img_params.in_right);
|
||||
SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params.ex_left_to_right);
|
||||
VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
|
||||
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
|
||||
VLOG(2) << "Extrinsics left to right: {"
|
||||
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
|
||||
} else {
|
||||
LOG(WARNING) << "Img intrinsics & extrinsics not exist";
|
||||
LOG(WARNING) << "Intrinsics & extrinsics not exist";
|
||||
}
|
||||
if (imu_params.ok) {
|
||||
imu_intrinsics_ = imu_params.in;
|
||||
imu_extrinsics_ = imu_params.ex;
|
||||
VLOG(2) << "ImuIntrinsics " << imu_intrinsics_;
|
||||
VLOG(2) << "ImuExtrinsics " << imu_extrinsics_;
|
||||
SetMotionIntrinsics({imu_params.in_accel, imu_params.in_gyro});
|
||||
SetMotionExtrinsics(Stream::LEFT, imu_params.ex_left_to_imu);
|
||||
VLOG(2) << "Motion intrinsics: {" << GetMotionIntrinsics() << "}";
|
||||
VLOG(2) << "Motion extrinsics left to imu: {"
|
||||
<< GetMotionExtrinsics(Stream::LEFT) << "}";
|
||||
} else {
|
||||
LOG(WARNING) << "Imu intrinsics & extrinsics not exist";
|
||||
}
|
||||
}
|
||||
|
||||
void Device::WriteDeviceInfo(const DeviceInfo &device_info) {
|
||||
CHECK_NOTNULL(channels_);
|
||||
DeviceInfo info = device_info;
|
||||
if (channels_->SetFiles(&info, nullptr, nullptr)) {
|
||||
device_info_->lens_type = info.lens_type;
|
||||
device_info_->imu_type = info.imu_type;
|
||||
device_info_->nominal_baseline = info.nominal_baseline;
|
||||
}
|
||||
}
|
||||
|
||||
void Device::WriteImgParams(
|
||||
const ImgIntrinsics &intrinsics, const ImgExtrinsics &extrinsics) {
|
||||
CHECK_NOTNULL(channels_);
|
||||
Channels::img_params_t img_params{false, intrinsics, extrinsics};
|
||||
if (channels_->SetFiles(
|
||||
nullptr, &img_params, nullptr, &device_info_->spec_version)) {
|
||||
img_intrinsics_ = intrinsics;
|
||||
img_extrinsics_ = extrinsics;
|
||||
}
|
||||
}
|
||||
|
||||
void Device::WriteImuParams(
|
||||
const ImuIntrinsics &intrinsics, const ImuExtrinsics &extrinsics) {
|
||||
CHECK_NOTNULL(channels_);
|
||||
Channels::imu_params_t imu_params{false, intrinsics, extrinsics};
|
||||
if (channels_->SetFiles(
|
||||
nullptr, nullptr, &imu_params, &device_info_->spec_version)) {
|
||||
imu_intrinsics_ = intrinsics;
|
||||
imu_extrinsics_ = extrinsics;
|
||||
LOG(WARNING) << "Motion intrinsics & extrinsics not exist";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,15 +57,16 @@ class Device {
|
|||
std::shared_ptr<DeviceInfo> GetInfo() const;
|
||||
std::string GetInfo(const Info &info) const;
|
||||
|
||||
ImgIntrinsics GetImgIntrinsics() const;
|
||||
ImgExtrinsics GetImgExtrinsics() const;
|
||||
void SetImgIntrinsics(const ImgIntrinsics &in);
|
||||
void SetImgExtrinsics(const ImgExtrinsics &ex);
|
||||
Intrinsics GetIntrinsics(const Stream &stream) const;
|
||||
Extrinsics GetExtrinsics(const Stream &from, const Stream &to) const;
|
||||
MotionIntrinsics GetMotionIntrinsics() const;
|
||||
Extrinsics GetMotionExtrinsics(const Stream &from) const;
|
||||
|
||||
ImuIntrinsics GetImuIntrinsics() const;
|
||||
ImuExtrinsics GetImuExtrinsics() const;
|
||||
void SetImuIntrinsics(const ImuIntrinsics &in);
|
||||
void SetImuExtrinsics(const ImuExtrinsics &ex);
|
||||
void SetIntrinsics(const Stream &stream, const Intrinsics &in);
|
||||
void SetExtrinsics(
|
||||
const Stream &from, const Stream &to, const Extrinsics &ex);
|
||||
void SetMotionIntrinsics(const MotionIntrinsics &in);
|
||||
void SetMotionExtrinsics(const Stream &from, const Extrinsics &ex);
|
||||
|
||||
void LogOptionInfos() const;
|
||||
OptionInfo GetOptionInfo(const Option &option) const;
|
||||
|
@ -120,10 +121,11 @@ class Device {
|
|||
std::shared_ptr<uvc::device> device_;
|
||||
std::shared_ptr<DeviceInfo> device_info_;
|
||||
|
||||
ImgIntrinsics img_intrinsics_;
|
||||
ImgExtrinsics img_extrinsics_;
|
||||
ImuIntrinsics imu_intrinsics_;
|
||||
ImuExtrinsics imu_extrinsics_;
|
||||
std::map<Stream, Intrinsics> stream_intrinsics_;
|
||||
std::map<Stream, std::map<Stream, Extrinsics>> stream_from_extrinsics_;
|
||||
|
||||
std::shared_ptr<MotionIntrinsics> motion_intrinsics_;
|
||||
std::map<Stream, Extrinsics> motion_from_extrinsics_;
|
||||
|
||||
stream_callbacks_t stream_callbacks_;
|
||||
motion_callback_t motion_callback_;
|
||||
|
@ -140,11 +142,9 @@ class Device {
|
|||
|
||||
void ReadAllInfos();
|
||||
|
||||
void WriteDeviceInfo(const DeviceInfo &device_info);
|
||||
void WriteImgParams(
|
||||
const ImgIntrinsics &intrinsics, const ImgExtrinsics &extrinsics);
|
||||
void WriteImuParams(
|
||||
const ImuIntrinsics &intrinsics, const ImuExtrinsics &extrinsics);
|
||||
std::shared_ptr<Channels> channels() {
|
||||
return channels_;
|
||||
}
|
||||
|
||||
// friend DeviceWriter;
|
||||
};
|
||||
|
|
|
@ -386,49 +386,64 @@ std::size_t from_data(Channels::device_info_t *info, const std::uint8_t *data) {
|
|||
}
|
||||
|
||||
std::size_t from_data(
|
||||
Channels::img_params_t *img_params, const std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
Intrinsics *in, const std::uint8_t *data, const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
|
||||
auto &&in = img_params->in;
|
||||
// width, 2
|
||||
in.width = _from_data<std::uint16_t>(data + i);
|
||||
in->width = _from_data<std::uint16_t>(data + i);
|
||||
i += 2;
|
||||
// height, 2
|
||||
in.height = _from_data<std::uint16_t>(data + i);
|
||||
in->height = _from_data<std::uint16_t>(data + i);
|
||||
i += 2;
|
||||
// fx, 8
|
||||
in.fx = _from_data<double>(data + i);
|
||||
in->fx = _from_data<double>(data + i);
|
||||
i += 8;
|
||||
// fy, 8
|
||||
in.fy = _from_data<double>(data + i);
|
||||
in->fy = _from_data<double>(data + i);
|
||||
i += 8;
|
||||
// cx, 8
|
||||
in.cx = _from_data<double>(data + i);
|
||||
in->cx = _from_data<double>(data + i);
|
||||
i += 8;
|
||||
// cy, 8
|
||||
in.cy = _from_data<double>(data + i);
|
||||
in->cy = _from_data<double>(data + i);
|
||||
i += 8;
|
||||
// model, 1
|
||||
in.model = data[i];
|
||||
in->model = data[i];
|
||||
i += 1;
|
||||
// coeffs, 40
|
||||
for (std::size_t j = 0; j < 5; j++) {
|
||||
in.coeffs[j] = _from_data<double>(data + i + j * 8);
|
||||
in->coeffs[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 40;
|
||||
|
||||
auto &&ex = img_params->ex.left_to_right;
|
||||
// rotation
|
||||
UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
std::size_t from_data(
|
||||
ImuIntrinsics *in, const std::uint8_t *data, const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
|
||||
// scale
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
ex.rotation[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
|
||||
in->scale[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// translation
|
||||
// drift
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
ex.translation[j] = _from_data<double>(data + i + j * 8);
|
||||
in->drift[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// noise
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
in->noise[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// bias
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
in->bias[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
|
||||
|
@ -437,67 +452,19 @@ std::size_t from_data(
|
|||
}
|
||||
|
||||
std::size_t from_data(
|
||||
Channels::imu_params_t *imu_params, const std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
Extrinsics *ex, const std::uint8_t *data, const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
|
||||
auto &&in = imu_params->in;
|
||||
// acc_scale
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
in.accel.scale[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// gyro_scale
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
in.gyro.scale[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// acc_drift
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
in.accel.drift[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// gyro_drift
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
in.gyro.drift[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// acc_noise
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
in.accel.noise[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// gyro_noise
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
in.gyro.noise[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// acc_bias
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
in.accel.bias[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// gyro_bias
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
in.gyro.bias[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
|
||||
auto &&ex = imu_params->ex.left_to_imu;
|
||||
// rotation
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
ex.rotation[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
|
||||
ex->rotation[j][k] = _from_data<double>(data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// translation
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
ex.translation[j] = _from_data<double>(data + i + j * 8);
|
||||
ex->translation[j] = _from_data<double>(data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
|
||||
|
@ -505,6 +472,26 @@ std::size_t from_data(
|
|||
return i;
|
||||
}
|
||||
|
||||
std::size_t from_data(
|
||||
Channels::img_params_t *img_params, const std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
i += from_data(&img_params->in_left, data + i, spec_version);
|
||||
i += from_data(&img_params->in_right, data + i, spec_version);
|
||||
i += from_data(&img_params->ex_left_to_right, data + i, spec_version);
|
||||
return i;
|
||||
}
|
||||
|
||||
std::size_t from_data(
|
||||
Channels::imu_params_t *imu_params, const std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
i += from_data(&imu_params->in_accel, data + i, spec_version);
|
||||
i += from_data(&imu_params->in_gyro, data + i, spec_version);
|
||||
i += from_data(&imu_params->ex_left_to_imu, data + i, spec_version);
|
||||
return i;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool Channels::GetFiles(
|
||||
|
@ -669,54 +656,99 @@ std::size_t to_data(
|
|||
}
|
||||
|
||||
std::size_t to_data(
|
||||
const Channels::img_params_t *img_params, std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 3; // skip id, size
|
||||
const Intrinsics *in, std::uint8_t *data, const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
|
||||
auto &&in = img_params->in;
|
||||
// width, 2
|
||||
_to_data(in.width, data + i);
|
||||
_to_data(in->width, data + i);
|
||||
i += 2;
|
||||
// height, 2
|
||||
_to_data(in.height, data + i);
|
||||
_to_data(in->height, data + i);
|
||||
i += 2;
|
||||
// fx, 8
|
||||
_to_data(in.fx, data + i);
|
||||
_to_data(in->fx, data + i);
|
||||
i += 8;
|
||||
// fy, 8
|
||||
_to_data(in.fy, data + i);
|
||||
_to_data(in->fy, data + i);
|
||||
i += 8;
|
||||
// cx, 8
|
||||
_to_data(in.cx, data + i);
|
||||
_to_data(in->cx, data + i);
|
||||
i += 8;
|
||||
// cy, 8
|
||||
_to_data(in.cy, data + i);
|
||||
_to_data(in->cy, data + i);
|
||||
i += 8;
|
||||
// model, 1
|
||||
data[i] = in.model;
|
||||
data[i] = in->model;
|
||||
i += 1;
|
||||
// coeffs, 40
|
||||
for (std::size_t j = 0; j < 5; j++) {
|
||||
_to_data(in.coeffs[j], data + i + j * 8);
|
||||
_to_data(in->coeffs[j], data + i + j * 8);
|
||||
}
|
||||
i += 40;
|
||||
|
||||
auto &&ex = img_params->ex.left_to_right;
|
||||
UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
std::size_t to_data(
|
||||
const ImuIntrinsics *in, std::uint8_t *data, const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
|
||||
// scale
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
_to_data(in->scale[j][k], data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// drift
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in->drift[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// noise
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in->noise[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// bias
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in->bias[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
|
||||
UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
std::size_t to_data(
|
||||
const Extrinsics *ex, std::uint8_t *data, const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
|
||||
// rotation
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
_to_data(ex.rotation[j][k], data + i + (j * 3 + k) * 8);
|
||||
_to_data(ex->rotation[j][k], data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// translation
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(ex.translation[j], data + i + j * 8);
|
||||
_to_data(ex->translation[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
|
||||
UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
std::size_t to_data(
|
||||
const Channels::img_params_t *img_params, std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 3; // skip id, size
|
||||
i += to_data(&img_params->in_left, data + i, spec_version);
|
||||
i += to_data(&img_params->in_right, data + i, spec_version);
|
||||
i += to_data(&img_params->ex_left_to_right, data + i, spec_version);
|
||||
// others
|
||||
std::size_t size = i - 3;
|
||||
data[0] = Channels::FID_IMG_PARAMS;
|
||||
|
@ -729,69 +761,9 @@ std::size_t to_data(
|
|||
const Channels::imu_params_t *imu_params, std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 3; // skip id, size
|
||||
|
||||
auto &&in = imu_params->in;
|
||||
// acc_scale
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
_to_data(in.accel.scale[j][k], data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// gyro_scale
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
_to_data(in.gyro.scale[j][k], data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// acc_drift
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in.accel.drift[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// gyro_drift
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in.gyro.drift[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// acc_noise
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in.accel.noise[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// gyro_noise
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in.gyro.noise[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// acc_bias
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in.accel.bias[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
// gyro_bias
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(in.gyro.bias[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
|
||||
auto &&ex = imu_params->ex.left_to_imu;
|
||||
// rotation
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
for (std::size_t k = 0; k < 3; k++) {
|
||||
_to_data(ex.rotation[j][k], data + i + (j * 3 + k) * 8);
|
||||
}
|
||||
}
|
||||
i += 72;
|
||||
// translation
|
||||
for (std::size_t j = 0; j < 3; j++) {
|
||||
_to_data(ex.translation[j], data + i + j * 8);
|
||||
}
|
||||
i += 24;
|
||||
|
||||
UNUSED(spec_version)
|
||||
|
||||
i += to_data(&imu_params->in_accel, data + i, spec_version);
|
||||
i += to_data(&imu_params->in_gyro, data + i, spec_version);
|
||||
i += to_data(&imu_params->ex_left_to_imu, data + i, spec_version);
|
||||
// others
|
||||
std::size_t size = i - 3;
|
||||
data[0] = Channels::FID_IMU_PARAMS;
|
||||
|
|
|
@ -57,14 +57,16 @@ class Channels {
|
|||
|
||||
typedef struct ImgParams {
|
||||
bool ok;
|
||||
ImgIntrinsics in;
|
||||
ImgExtrinsics ex;
|
||||
Intrinsics in_left;
|
||||
Intrinsics in_right;
|
||||
Extrinsics ex_left_to_right;
|
||||
} img_params_t;
|
||||
|
||||
typedef struct ImuParams {
|
||||
bool ok;
|
||||
ImuIntrinsics in;
|
||||
ImuExtrinsics ex;
|
||||
ImuIntrinsics in_accel;
|
||||
ImuIntrinsics in_gyro;
|
||||
Extrinsics ex_left_to_imu;
|
||||
} imu_params_t;
|
||||
|
||||
explicit Channels(std::shared_ptr<uvc::device> device);
|
||||
|
|
|
@ -145,7 +145,7 @@ std::ostream &operator<<(std::ostream &os, const StreamRequest &request) {
|
|||
<< ", format: " << request.format << ", fps: " << request.fps;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImgIntrinsics &in) {
|
||||
std::ostream &operator<<(std::ostream &os, const Intrinsics &in) {
|
||||
os << "width: " << in.width << ", height: " << in.height << ", fx: " << in.fx
|
||||
<< ", fy: " << in.fy << ", cx: " << in.cx << ", cy: " << in.cy
|
||||
<< ", model: " << static_cast<int>(in.model) << ", coeffs: [";
|
||||
|
@ -154,7 +154,7 @@ std::ostream &operator<<(std::ostream &os, const ImgIntrinsics &in) {
|
|||
return os << in.coeffs[4] << "]";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImuSensorIntrinsics &in) {
|
||||
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in) {
|
||||
os << "scale: [";
|
||||
for (int i = 0; i <= 2; i++)
|
||||
os << in.scale[0][i] << ", ";
|
||||
|
@ -182,7 +182,7 @@ std::ostream &operator<<(std::ostream &os, const ImuSensorIntrinsics &in) {
|
|||
return os;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in) {
|
||||
std::ostream &operator<<(std::ostream &os, const MotionIntrinsics &in) {
|
||||
return os << "accel: {" << in.accel << "}, gyro: {" << in.gyro << "}";
|
||||
}
|
||||
|
||||
|
@ -204,12 +204,4 @@ std::ostream &operator<<(std::ostream &os, const Extrinsics &ex) {
|
|||
return os;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImgExtrinsics &ex) {
|
||||
return os << "left_to_right: {" << ex.left_to_right << "}";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ImuExtrinsics &ex) {
|
||||
return os << "left_to_imu: {" << ex.left_to_imu << "}";
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
|
Loading…
Reference in New Issue
Block a user