diff --git a/include/mynteye/api/api.h b/include/mynteye/api/api.h index 469e680..f4ce9bb 100644 --- a/include/mynteye/api/api.h +++ b/include/mynteye/api/api.h @@ -93,7 +93,7 @@ class MYNTEYE_API API { /** The api::MotionData callback. */ using motion_callback_t = std::function; - explicit API(std::shared_ptr device); + explicit API(std::shared_ptr device, CalibrationModel calib_model); virtual ~API(); /** diff --git a/src/mynteye/api/api.cc b/src/mynteye/api/api.cc index 1299bdb..d7471e5 100644 --- a/src/mynteye/api/api.cc +++ b/src/mynteye/api/api.cc @@ -207,10 +207,11 @@ std::vector get_plugin_paths() { } // namespace -API::API(std::shared_ptr device) : device_(device) { +API::API(std::shared_ptr device, CalibrationModel calib_model) + : device_(device) { VLOG(2) << __func__; // std::dynamic_pointer_cast(device_); - synthetic_.reset(new Synthetic(this)); + synthetic_.reset(new Synthetic(this, calib_model)); } API::~API() { @@ -230,7 +231,15 @@ std::shared_ptr API::Create( } std::shared_ptr API::Create(const std::shared_ptr &device) { - return std::make_shared(device); + auto left_intr = device -> GetIntrinsics(Stream::LEFT); + auto right_intr = device -> GetIntrinsics(Stream::RIGHT); + if (left_intr->calib_model() != right_intr->calib_model()) { + VLOG(2) << __func__ + << "ERROR: " + <<"left camera and right camera use different calib models!"; + } + auto api = std::make_shared(device, left_intr->calib_model()); + return api; } Model API::GetModel() const { diff --git a/src/mynteye/api/processor/rectify_processor.cc b/src/mynteye/api/processor/rectify_processor.cc index 6fa5ca6..585ed12 100644 --- a/src/mynteye/api/processor/rectify_processor.cc +++ b/src/mynteye/api/processor/rectify_processor.cc @@ -24,6 +24,13 @@ #ifdef WITH_CAM_MODELS +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/mynteye/api/processor/rectify_processor.h b/src/mynteye/api/processor/rectify_processor.h index cdfd3b5..eda5b6c 100644 --- a/src/mynteye/api/processor/rectify_processor.h +++ b/src/mynteye/api/processor/rectify_processor.h @@ -22,15 +22,6 @@ #include "mynteye/types.h" #include "mynteye/api/processor.h" -#ifdef WITH_CAM_MODELS -#include -#include -#include -#include -#include -#include -#include -#endif MYNTEYE_BEGIN_NAMESPACE diff --git a/src/mynteye/api/synthetic.cc b/src/mynteye/api/synthetic.cc index 22b7b17..bb3504b 100644 --- a/src/mynteye/api/synthetic.cc +++ b/src/mynteye/api/synthetic.cc @@ -68,7 +68,8 @@ void process_childs( } // namespace -Synthetic::Synthetic(API *api) : api_(api), plugin_(nullptr) { +Synthetic::Synthetic(API *api, CalibrationModel calib_model) + : api_(api), plugin_(nullptr), calib_model_(calib_model) { VLOG(2) << __func__; CHECK_NOTNULL(api_); InitStreamSupports(); @@ -442,10 +443,21 @@ void Synthetic::InitProcessors() { depth_processor->SetPostProcessCallback( std::bind(&Synthetic::OnDepthPostProcess, this, _1)); - rectify_processor->AddChild(disparity_processor); - disparity_processor->AddChild(disparitynormalized_processor); - disparity_processor->AddChild(points_processor); - points_processor->AddChild(depth_processor); + if (calib_model_ == CalibrationModel::PINHOLE) { + // PINHOLE + rectify_processor->AddChild(disparity_processor); + disparity_processor->AddChild(disparitynormalized_processor); + disparity_processor->AddChild(points_processor); + points_processor->AddChild(depth_processor); + } else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) { + // KANNALA_BRANDT + rectify_processor->AddChild(disparity_processor); + disparity_processor->AddChild(disparitynormalized_processor); + disparity_processor->AddChild(points_processor); + points_processor->AddChild(depth_processor); + } else { + // UNKNOW + } processor_ = rectify_processor; } diff --git a/src/mynteye/api/synthetic.h b/src/mynteye/api/synthetic.h index 27c9d44..7179d9a 100644 --- a/src/mynteye/api/synthetic.h +++ b/src/mynteye/api/synthetic.h @@ -21,6 +21,7 @@ #include #include "mynteye/api/api.h" +// #include "" MYNTEYE_BEGIN_NAMESPACE @@ -40,7 +41,7 @@ class Synthetic { MODE_LAST // Unsupported } mode_t; - explicit Synthetic(API *api); + explicit Synthetic(API *api, CalibrationModel calib_model); ~Synthetic(); void NotifyImageParamsChanged(); @@ -112,6 +113,8 @@ class Synthetic { std::shared_ptr processor_; std::shared_ptr plugin_; + + CalibrationModel calib_model_; }; template