fix(processor): fix reload image params bug
This commit is contained in:
parent
7746d2b116
commit
883aef5341
|
@ -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<IntrinsicsEquidistant>(intr_left),
|
||||
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(intr_right),
|
||||
*extr);
|
||||
}
|
||||
|
||||
RectifyProcessor::~RectifyProcessor() {
|
||||
|
@ -396,11 +396,14 @@ std::string RectifyProcessor::Name() {
|
|||
return NAME;
|
||||
}
|
||||
|
||||
void RectifyProcessor::NotifyImageParamsChanged() {
|
||||
void RectifyProcessor::ReloadImageParams(
|
||||
std::shared_ptr<IntrinsicsBase> intr_left,
|
||||
std::shared_ptr<IntrinsicsBase> intr_right,
|
||||
std::shared_ptr<Extrinsics> extr) {
|
||||
InitParams(
|
||||
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(intr_left_),
|
||||
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(intr_right_),
|
||||
*extr_);
|
||||
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(intr_left),
|
||||
*std::dynamic_pointer_cast<IntrinsicsEquidistant>(intr_right),
|
||||
*extr);
|
||||
}
|
||||
|
||||
Object *RectifyProcessor::OnCreateOutput() {
|
||||
|
|
|
@ -71,7 +71,10 @@ class RectifyProcessor : public Processor {
|
|||
|
||||
std::string Name() override;
|
||||
|
||||
void NotifyImageParamsChanged();
|
||||
void ReloadImageParams(
|
||||
std::shared_ptr<IntrinsicsBase> intr_left,
|
||||
std::shared_ptr<IntrinsicsBase> intr_right,
|
||||
std::shared_ptr<Extrinsics> 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<IntrinsicsBase> intr_left_;
|
||||
std::shared_ptr<IntrinsicsBase> intr_right_;
|
||||
std::shared_ptr<Extrinsics> extr_;
|
||||
CalibrationModel calib_model;
|
||||
std::shared_ptr<struct camera_calib_info_pair> calib_infos;
|
||||
};
|
||||
|
|
|
@ -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<IntrinsicsPinhole>(intr_left),
|
||||
*std::dynamic_pointer_cast<IntrinsicsPinhole>(intr_right),
|
||||
*extr);
|
||||
}
|
||||
|
||||
RectifyProcessorOCV::~RectifyProcessorOCV() {
|
||||
|
@ -46,11 +46,14 @@ std::string RectifyProcessorOCV::Name() {
|
|||
return NAME;
|
||||
}
|
||||
|
||||
void RectifyProcessorOCV::NotifyImageParamsChanged() {
|
||||
void RectifyProcessorOCV::ReloadImageParams(
|
||||
std::shared_ptr<IntrinsicsBase> intr_left,
|
||||
std::shared_ptr<IntrinsicsBase> intr_right,
|
||||
std::shared_ptr<Extrinsics> extr) {
|
||||
InitParams(
|
||||
*std::dynamic_pointer_cast<IntrinsicsPinhole>(intr_left_),
|
||||
*std::dynamic_pointer_cast<IntrinsicsPinhole>(intr_right_),
|
||||
*extr_);
|
||||
*std::dynamic_pointer_cast<IntrinsicsPinhole>(intr_left),
|
||||
*std::dynamic_pointer_cast<IntrinsicsPinhole>(intr_right),
|
||||
*extr);
|
||||
}
|
||||
|
||||
Object *RectifyProcessorOCV::OnCreateOutput() {
|
||||
|
|
|
@ -40,7 +40,10 @@ class RectifyProcessorOCV : public Processor {
|
|||
|
||||
std::string Name() override;
|
||||
|
||||
void NotifyImageParamsChanged();
|
||||
void ReloadImageParams(
|
||||
std::shared_ptr<IntrinsicsBase> intr_left,
|
||||
std::shared_ptr<IntrinsicsBase> intr_right,
|
||||
std::shared_ptr<Extrinsics> 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<IntrinsicsBase> intr_left_;
|
||||
std::shared_ptr<IntrinsicsBase> intr_right_;
|
||||
std::shared_ptr<Extrinsics> extr_;
|
||||
|
||||
CalibrationModel calib_model;
|
||||
};
|
||||
|
||||
|
|
|
@ -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<Extrinsics>(
|
||||
api_->GetExtrinsics(Stream::LEFT, Stream::RIGHT));
|
||||
if (calib_model_ == CalibrationModel::PINHOLE) {
|
||||
auto &&processor = find_processor<RectifyProcessorOCV>(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<RectifyProcessor>(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<RectifyProcessorOCV>(processor_);
|
||||
if (processor) processor->NotifyImageParamsChanged();
|
||||
if (processor) processor->ReloadImageParams(intr_left_, intr_right_, extr_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user