fix(calib models): default work improve

This commit is contained in:
TinyOh 2019-01-14 16:40:05 +08:00
parent d42b8ef69c
commit e46c9371db
2 changed files with 10 additions and 9 deletions

View File

@ -90,6 +90,7 @@ void Synthetic::InitCalibInfo() {
api_->GetExtrinsics(Stream::LEFT, Stream::RIGHT)); api_->GetExtrinsics(Stream::LEFT, Stream::RIGHT));
#endif #endif
} else { } else {
calib_default_tag_ = true;
calib_model_ = CalibrationModel::PINHOLE; calib_model_ = CalibrationModel::PINHOLE;
LOG(INFO) << "camera calib model: unknow ,use default pinhole data"; LOG(INFO) << "camera calib model: unknow ,use default pinhole data";
intr_left_ = getDefaultIntrinsics(); intr_left_ = getDefaultIntrinsics();
@ -101,7 +102,8 @@ void Synthetic::InitCalibInfo() {
Synthetic::Synthetic(API *api, CalibrationModel calib_model) Synthetic::Synthetic(API *api, CalibrationModel calib_model)
: api_(api), : api_(api),
plugin_(nullptr), plugin_(nullptr),
calib_model_(calib_model) { calib_model_(calib_model),
calib_default_tag_(false) {
VLOG(2) << __func__; VLOG(2) << __func__;
CHECK_NOTNULL(api_); CHECK_NOTNULL(api_);
InitCalibInfo(); InitCalibInfo();
@ -117,20 +119,18 @@ Synthetic::~Synthetic() {
} }
} }
void Synthetic::NotifyImageParamsChanged(bool is_from_dev) { void Synthetic::NotifyImageParamsChanged() {
if (is_from_dev && calib_model_ == CalibrationModel::PINHOLE) { if (!calib_default_tag_) {
intr_left_ = api_->GetIntrinsicsBase(Stream::LEFT); intr_left_ = api_->GetIntrinsicsBase(Stream::LEFT);
intr_right_ = api_->GetIntrinsicsBase(Stream::RIGHT); intr_right_ = api_->GetIntrinsicsBase(Stream::RIGHT);
extr_ = std::make_shared<Extrinsics>( extr_ = std::make_shared<Extrinsics>(
api_->GetExtrinsics(Stream::LEFT, Stream::RIGHT)); api_->GetExtrinsics(Stream::LEFT, Stream::RIGHT));
}
if (calib_model_ == CalibrationModel::PINHOLE) {
auto &&processor = find_processor<RectifyProcessorOCV>(processor_); auto &&processor = find_processor<RectifyProcessorOCV>(processor_);
if (processor) processor->ReloadImageParams(intr_left_, intr_right_, extr_); if (processor) processor->ReloadImageParams(intr_left_, intr_right_, extr_);
#ifdef WITH_CAM_MODELS #ifdef WITH_CAM_MODELS
} else if (is_from_dev && calib_model_ == CalibrationModel::KANNALA_BRANDT) { } else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) {
intr_left_ = api_->GetIntrinsicsBase(Stream::LEFT);
intr_right_ = api_->GetIntrinsicsBase(Stream::RIGHT);
extr_ = std::make_shared<Extrinsics>(
api_->GetExtrinsics(Stream::LEFT, Stream::RIGHT));
auto &&processor = find_processor<RectifyProcessor>(processor_); auto &&processor = find_processor<RectifyProcessor>(processor_);
if (processor) processor->ReloadImageParams(intr_left_, intr_right_, extr_); if (processor) processor->ReloadImageParams(intr_left_, intr_right_, extr_);
#endif #endif

View File

@ -44,7 +44,7 @@ class Synthetic {
explicit Synthetic(API *api, CalibrationModel calib_model); explicit Synthetic(API *api, CalibrationModel calib_model);
~Synthetic(); ~Synthetic();
void NotifyImageParamsChanged(bool is_from_dev = false); void NotifyImageParamsChanged();
bool Supports(const Stream &stream) const; bool Supports(const Stream &stream) const;
mode_t SupportsMode(const Stream &stream) const; mode_t SupportsMode(const Stream &stream) const;
@ -120,6 +120,7 @@ class Synthetic {
std::shared_ptr<IntrinsicsBase> intr_left_; std::shared_ptr<IntrinsicsBase> intr_left_;
std::shared_ptr<IntrinsicsBase> intr_right_; std::shared_ptr<IntrinsicsBase> intr_right_;
std::shared_ptr<Extrinsics> extr_; std::shared_ptr<Extrinsics> extr_;
bool calib_default_tag_;
}; };
template <class T, class P> template <class T, class P>