refactor(types): protected calib model member
This commit is contained in:
parent
c580f6e8dc
commit
05c5c1f238
|
@ -417,16 +417,21 @@ inline std::ostream &operator<<(std::ostream &os,
|
||||||
|
|
||||||
struct MYNTEYE_API IntrinsicsBase {
|
struct MYNTEYE_API IntrinsicsBase {
|
||||||
IntrinsicsBase() {
|
IntrinsicsBase() {
|
||||||
calib_model = CalibrationModel::UNKNOW;
|
calib_model_ = CalibrationModel::UNKNOW;
|
||||||
}
|
}
|
||||||
virtual ~IntrinsicsBase() {}
|
virtual ~IntrinsicsBase() {}
|
||||||
|
|
||||||
/** The calibration model */
|
/** The calibration model */
|
||||||
CalibrationModel calib_model;
|
CalibrationModel calib_model() const {
|
||||||
|
return calib_model_;
|
||||||
|
}
|
||||||
/** The width of the image in pixels */
|
/** The width of the image in pixels */
|
||||||
std::uint16_t width;
|
std::uint16_t width;
|
||||||
/** The height of the image in pixels */
|
/** The height of the image in pixels */
|
||||||
std::uint16_t height;
|
std::uint16_t height;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CalibrationModel calib_model_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -435,7 +440,7 @@ struct MYNTEYE_API IntrinsicsBase {
|
||||||
*/
|
*/
|
||||||
struct MYNTEYE_API IntrinsicsPinhole : public IntrinsicsBase {
|
struct MYNTEYE_API IntrinsicsPinhole : public IntrinsicsBase {
|
||||||
IntrinsicsPinhole() {
|
IntrinsicsPinhole() {
|
||||||
calib_model = CalibrationModel::PINHOLE;
|
calib_model_ = CalibrationModel::PINHOLE;
|
||||||
}
|
}
|
||||||
/** The focal length of the image plane, as a multiple of pixel width */
|
/** The focal length of the image plane, as a multiple of pixel width */
|
||||||
double fx;
|
double fx;
|
||||||
|
@ -465,7 +470,7 @@ using Intrinsics = IntrinsicsPinhole;
|
||||||
*/
|
*/
|
||||||
struct MYNTEYE_API IntrinsicsEquidistant : public IntrinsicsBase {
|
struct MYNTEYE_API IntrinsicsEquidistant : public IntrinsicsBase {
|
||||||
IntrinsicsEquidistant() {
|
IntrinsicsEquidistant() {
|
||||||
calib_model = CalibrationModel::KANNALA_BRANDT;
|
calib_model_ = CalibrationModel::KANNALA_BRANDT;
|
||||||
}
|
}
|
||||||
/** The distortion coefficients: k2,k3,k4,k5,mu,mv,u0,v0 */
|
/** The distortion coefficients: k2,k3,k4,k5,mu,mv,u0,v0 */
|
||||||
double coeffs[8];
|
double coeffs[8];
|
||||||
|
|
|
@ -296,7 +296,7 @@ std::string API::GetInfo(const Info &info) const {
|
||||||
|
|
||||||
IntrinsicsPinhole API::GetIntrinsics(const Stream &stream) const {
|
IntrinsicsPinhole API::GetIntrinsics(const Stream &stream) const {
|
||||||
auto in = GetIntrinsicsBase(stream);
|
auto in = GetIntrinsicsBase(stream);
|
||||||
if (in->calib_model == CalibrationModel::PINHOLE) {
|
if (in->calib_model() == CalibrationModel::PINHOLE) {
|
||||||
return *std::dynamic_pointer_cast<IntrinsicsPinhole>(in);
|
return *std::dynamic_pointer_cast<IntrinsicsPinhole>(in);
|
||||||
}
|
}
|
||||||
throw std::runtime_error("Intrinsics is not pinhole model"
|
throw std::runtime_error("Intrinsics is not pinhole model"
|
||||||
|
|
|
@ -43,12 +43,12 @@ std::string RectifyProcessor::Name() {
|
||||||
void RectifyProcessor::NotifyImageParamsChanged() {
|
void RectifyProcessor::NotifyImageParamsChanged() {
|
||||||
auto in_left = device_->GetIntrinsics(Stream::LEFT);
|
auto in_left = device_->GetIntrinsics(Stream::LEFT);
|
||||||
auto in_right = device_->GetIntrinsics(Stream::RIGHT);
|
auto in_right = device_->GetIntrinsics(Stream::RIGHT);
|
||||||
if (in_left->calib_model == CalibrationModel::PINHOLE) {
|
if (in_left->calib_model() == CalibrationModel::PINHOLE) {
|
||||||
InitParams(
|
InitParams(
|
||||||
*std::dynamic_pointer_cast<IntrinsicsPinhole>(in_left),
|
*std::dynamic_pointer_cast<IntrinsicsPinhole>(in_left),
|
||||||
*std::dynamic_pointer_cast<IntrinsicsPinhole>(in_right),
|
*std::dynamic_pointer_cast<IntrinsicsPinhole>(in_right),
|
||||||
device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT));
|
device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT));
|
||||||
} else if (in_left->calib_model ==
|
} else if (in_left->calib_model() ==
|
||||||
CalibrationModel::KANNALA_BRANDT) {
|
CalibrationModel::KANNALA_BRANDT) {
|
||||||
InitParams(
|
InitParams(
|
||||||
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(in_left),
|
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(in_left),
|
||||||
|
|
|
@ -32,7 +32,7 @@ std::string _from_data(const std::uint8_t *data, std::size_t count) {
|
||||||
|
|
||||||
std::size_t from_data(IntrinsicsBase *in, const std::uint8_t *data,
|
std::size_t from_data(IntrinsicsBase *in, const std::uint8_t *data,
|
||||||
bool get_size) {
|
bool get_size) {
|
||||||
switch (in->calib_model) {
|
switch (in->calib_model()) {
|
||||||
case CalibrationModel::PINHOLE:
|
case CalibrationModel::PINHOLE:
|
||||||
return from_data(dynamic_cast<IntrinsicsPinhole *>(in), data,
|
return from_data(dynamic_cast<IntrinsicsPinhole *>(in), data,
|
||||||
get_size);
|
get_size);
|
||||||
|
@ -40,7 +40,7 @@ std::size_t from_data(IntrinsicsBase *in, const std::uint8_t *data,
|
||||||
return from_data(dynamic_cast<IntrinsicsEquidistant *>(in), data,
|
return from_data(dynamic_cast<IntrinsicsEquidistant *>(in), data,
|
||||||
get_size);
|
get_size);
|
||||||
default:
|
default:
|
||||||
LOG(FATAL) << "Unknown calib model: " << in->calib_model;
|
LOG(FATAL) << "Unknown calib model: " << in->calib_model();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ std::size_t _to_data(std::string value, std::uint8_t *data, std::size_t count) {
|
||||||
|
|
||||||
std::size_t to_data(const IntrinsicsBase *in, std::uint8_t *data,
|
std::size_t to_data(const IntrinsicsBase *in, std::uint8_t *data,
|
||||||
bool set_size) {
|
bool set_size) {
|
||||||
switch (in->calib_model) {
|
switch (in->calib_model()) {
|
||||||
case CalibrationModel::PINHOLE:
|
case CalibrationModel::PINHOLE:
|
||||||
return to_data(dynamic_cast<const IntrinsicsPinhole *>(in), data,
|
return to_data(dynamic_cast<const IntrinsicsPinhole *>(in), data,
|
||||||
set_size);
|
set_size);
|
||||||
|
@ -171,7 +171,7 @@ std::size_t to_data(const IntrinsicsBase *in, std::uint8_t *data,
|
||||||
return to_data(dynamic_cast<const IntrinsicsEquidistant *>(in), data,
|
return to_data(dynamic_cast<const IntrinsicsEquidistant *>(in), data,
|
||||||
set_size);
|
set_size);
|
||||||
default:
|
default:
|
||||||
LOG(FATAL) << "Unknown calib model: " << in->calib_model;
|
LOG(FATAL) << "Unknown calib model: " << in->calib_model();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -334,10 +334,8 @@ std::size_t ImgParamsParser::GetFromData_new(
|
||||||
i += bytes::from_data(in_left.get(), data + i, false);
|
i += bytes::from_data(in_left.get(), data + i, false);
|
||||||
i += bytes::from_data(in_right.get(), data + i, false);
|
i += bytes::from_data(in_right.get(), data + i, false);
|
||||||
i += bytes::from_data(&ex_right_to_left, data + i);
|
i += bytes::from_data(&ex_right_to_left, data + i);
|
||||||
in_left->calib_model = calib_model;
|
|
||||||
in_left->width = width;
|
in_left->width = width;
|
||||||
in_left->height = height;
|
in_left->height = height;
|
||||||
in_right->calib_model = calib_model;
|
|
||||||
in_right->width = width;
|
in_right->width = width;
|
||||||
in_right->height = height;
|
in_right->height = height;
|
||||||
(*img_params)[{width, height}] = {true, version.to_string(),
|
(*img_params)[{width, height}] = {true, version.to_string(),
|
||||||
|
@ -369,7 +367,7 @@ std::size_t ImgParamsParser::SetToData_new(
|
||||||
for (auto &&entry : *img_params) {
|
for (auto &&entry : *img_params) {
|
||||||
auto &¶ms = entry.second;
|
auto &¶ms = entry.second;
|
||||||
// calib_model, 1
|
// calib_model, 1
|
||||||
data[i] = static_cast<std::uint8_t>(params.in_left->calib_model);
|
data[i] = static_cast<std::uint8_t>(params.in_left->calib_model());
|
||||||
i += 1;
|
i += 1;
|
||||||
// width, 2
|
// width, 2
|
||||||
bytes::_to_data(params.in_left->width, data + i);
|
bytes::_to_data(params.in_left->width, data + i);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user