diff --git a/src/mynteye/api/processor/rectify_processor.cc b/src/mynteye/api/processor/rectify_processor.cc index 731935f..cf34e73 100644 --- a/src/mynteye/api/processor/rectify_processor.cc +++ b/src/mynteye/api/processor/rectify_processor.cc @@ -381,11 +381,11 @@ RectifyProcessor::RectifyProcessor( std::int32_t proc_period) : Processor(std::move(proc_period)), calib_model(CalibrationModel::UNKNOW) { - intr_left_ = intr_left; - intr_right_ = intr_right; - extr_ = extr; VLOG(2) << __func__ << ": proc_period=" << proc_period; - NotifyImageParamsChanged(); + InitParams( + *std::dynamic_pointer_cast(intr_left), + *std::dynamic_pointer_cast(intr_right), + *extr); } RectifyProcessor::~RectifyProcessor() { @@ -396,11 +396,14 @@ std::string RectifyProcessor::Name() { return NAME; } -void RectifyProcessor::NotifyImageParamsChanged() { +void RectifyProcessor::ReloadImageParams( + std::shared_ptr intr_left, + std::shared_ptr intr_right, + std::shared_ptr extr) { InitParams( - *std::dynamic_pointer_cast(intr_left_), - *std::dynamic_pointer_cast(intr_right_), - *extr_); + *std::dynamic_pointer_cast(intr_left), + *std::dynamic_pointer_cast(intr_right), + *extr); } Object *RectifyProcessor::OnCreateOutput() { diff --git a/src/mynteye/api/processor/rectify_processor.h b/src/mynteye/api/processor/rectify_processor.h index 046b186..9721a38 100644 --- a/src/mynteye/api/processor/rectify_processor.h +++ b/src/mynteye/api/processor/rectify_processor.h @@ -71,7 +71,10 @@ class RectifyProcessor : public Processor { std::string Name() override; - void NotifyImageParamsChanged(); + void ReloadImageParams( + std::shared_ptr intr_left, + std::shared_ptr intr_right, + std::shared_ptr extr); cv::Mat R1, P1, R2, P2, Q; cv::Mat map11, map12, map21, map22; @@ -117,9 +120,6 @@ class RectifyProcessor : public Processor { camodocal::CameraPtr generateCameraFromIntrinsicsEquidistant( const mynteye::IntrinsicsEquidistant & in); - std::shared_ptr intr_left_; - std::shared_ptr intr_right_; - std::shared_ptr extr_; CalibrationModel calib_model; std::shared_ptr calib_infos; }; diff --git a/src/mynteye/api/processor/rectify_processor_ocv.cc b/src/mynteye/api/processor/rectify_processor_ocv.cc index f662cd7..5decbb1 100644 --- a/src/mynteye/api/processor/rectify_processor_ocv.cc +++ b/src/mynteye/api/processor/rectify_processor_ocv.cc @@ -32,10 +32,10 @@ RectifyProcessorOCV::RectifyProcessorOCV( : Processor(std::move(proc_period)), calib_model(CalibrationModel::UNKNOW) { VLOG(2) << __func__ << ": proc_period=" << proc_period; - intr_left_ = intr_left; - intr_right_ = intr_right; - extr_ = extr; - NotifyImageParamsChanged(); + InitParams( + *std::dynamic_pointer_cast(intr_left), + *std::dynamic_pointer_cast(intr_right), + *extr); } RectifyProcessorOCV::~RectifyProcessorOCV() { @@ -46,11 +46,14 @@ std::string RectifyProcessorOCV::Name() { return NAME; } -void RectifyProcessorOCV::NotifyImageParamsChanged() { +void RectifyProcessorOCV::ReloadImageParams( + std::shared_ptr intr_left, + std::shared_ptr intr_right, + std::shared_ptr extr) { InitParams( - *std::dynamic_pointer_cast(intr_left_), - *std::dynamic_pointer_cast(intr_right_), - *extr_); + *std::dynamic_pointer_cast(intr_left), + *std::dynamic_pointer_cast(intr_right), + *extr); } Object *RectifyProcessorOCV::OnCreateOutput() { diff --git a/src/mynteye/api/processor/rectify_processor_ocv.h b/src/mynteye/api/processor/rectify_processor_ocv.h index f9ea949..e67c4ae 100644 --- a/src/mynteye/api/processor/rectify_processor_ocv.h +++ b/src/mynteye/api/processor/rectify_processor_ocv.h @@ -40,7 +40,10 @@ class RectifyProcessorOCV : public Processor { std::string Name() override; - void NotifyImageParamsChanged(); + void ReloadImageParams( + std::shared_ptr intr_left, + std::shared_ptr intr_right, + std::shared_ptr extr); cv::Mat R1, P1, R2, P2, Q; cv::Mat map11, map12, map21, map22; @@ -54,10 +57,6 @@ class RectifyProcessorOCV : public Processor { void InitParams(IntrinsicsPinhole in_left, IntrinsicsPinhole in_right, Extrinsics ex_right_to_left); - std::shared_ptr intr_left_; - std::shared_ptr intr_right_; - std::shared_ptr extr_; - CalibrationModel calib_model; }; diff --git a/src/mynteye/api/synthetic.cc b/src/mynteye/api/synthetic.cc index 4265a76..ef5c14d 100644 --- a/src/mynteye/api/synthetic.cc +++ b/src/mynteye/api/synthetic.cc @@ -111,19 +111,23 @@ Synthetic::~Synthetic() { } void Synthetic::NotifyImageParamsChanged() { + intr_left_ = api_->GetIntrinsicsBase(Stream::LEFT); + intr_right_ = api_->GetIntrinsicsBase(Stream::RIGHT); + extr_ = std::make_shared( + api_->GetExtrinsics(Stream::LEFT, Stream::RIGHT)); if (calib_model_ == CalibrationModel::PINHOLE) { auto &&processor = find_processor(processor_); - if (processor) processor->NotifyImageParamsChanged(); + if (processor) processor->ReloadImageParams(intr_left_, intr_right_, extr_); #ifdef WITH_CAM_MODELS } else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) { auto &&processor = find_processor(processor_); - if (processor) processor->NotifyImageParamsChanged(); + if (processor) processor->ReloadImageParams(intr_left_, intr_right_, extr_); #endif } else { LOG(ERROR) << "Unknow calib model type in device: " << calib_model_ << ", use default pinhole model"; auto &&processor = find_processor(processor_); - if (processor) processor->NotifyImageParamsChanged(); + if (processor) processor->ReloadImageParams(intr_left_, intr_right_, extr_); } }