fix(calib model): default config now work

This commit is contained in:
TinyOh 2019-01-14 16:06:35 +08:00
parent 60ea66b1ec
commit d42b8ef69c
5 changed files with 32 additions and 14 deletions

View File

@ -235,6 +235,7 @@ if(WITH_API)
src/mynteye/api/processor/points_processor_ocv.cc src/mynteye/api/processor/points_processor_ocv.cc
src/mynteye/api/processor/depth_processor_ocv.cc src/mynteye/api/processor/depth_processor_ocv.cc
src/mynteye/api/processor/rectify_processor_ocv.cc src/mynteye/api/processor/rectify_processor_ocv.cc
src/mynteye/api/config.cc
) )
if(WITH_CAM_MODELS) if(WITH_CAM_MODELS)
list(APPEND MYNTEYE_SRCS list(APPEND MYNTEYE_SRCS

View File

@ -246,13 +246,16 @@ std::shared_ptr<API> API::Create(const std::shared_ptr<Device> &device) {
"to learn more."; "to learn more.";
LOG(WARNING) << "use pinhole as default"; LOG(WARNING) << "use pinhole as default";
api = std::make_shared<API>(device, CalibrationModel::UNKNOW); api = std::make_shared<API>(device, CalibrationModel::UNKNOW);
return api;
} else { } else {
if (left_intr->calib_model() != right_intr->calib_model()) { if (left_intr->calib_model() != right_intr->calib_model()) {
LOG(ERROR) << "left camera and right camera use different calib models!"; LOG(ERROR) << "left camera and right camera use different calib models!";
LOG(WARNING) << "use pinhole as default"; LOG(WARNING) << "use pinhole as default";
api = std::make_shared<API>(device, CalibrationModel::UNKNOW); api = std::make_shared<API>(device, CalibrationModel::UNKNOW);
return api;
} else { } else {
api = std::make_shared<API>(device, left_intr->calib_model()); api = std::make_shared<API>(device, left_intr->calib_model());
return api;
} }
} }
} else { } else {

View File

@ -21,6 +21,9 @@ MYNTEYE_BEGIN_NAMESPACE
std::shared_ptr<IntrinsicsBase> getDefaultIntrinsics() { std::shared_ptr<IntrinsicsBase> getDefaultIntrinsics() {
auto res = std::make_shared<IntrinsicsPinhole>(); auto res = std::make_shared<IntrinsicsPinhole>();
res->width = 640;
res->height = 400;
res->model = 0;
res->fx = 3.6220059643202876e+02; res->fx = 3.6220059643202876e+02;
res->fy = 3.6350065250745848e+02; res->fy = 3.6350065250745848e+02;
res->cx = 4.0658699068023441e+02; res->cx = 4.0658699068023441e+02;

View File

@ -28,6 +28,7 @@
#include "mynteye/api/processor/rectify_processor_ocv.h" #include "mynteye/api/processor/rectify_processor_ocv.h"
#include "mynteye/api/processor/depth_processor_ocv.h" #include "mynteye/api/processor/depth_processor_ocv.h"
#include "mynteye/api/processor/points_processor_ocv.h" #include "mynteye/api/processor/points_processor_ocv.h"
#include "mynteye/api/config.h"
#ifdef WITH_CAM_MODELS #ifdef WITH_CAM_MODELS
#include "mynteye/api/processor/depth_processor.h" #include "mynteye/api/processor/depth_processor.h"
#include "mynteye/api/processor/points_processor.h" #include "mynteye/api/processor/points_processor.h"
@ -74,20 +75,26 @@ void process_childs(
} // namespace } // namespace
void Synthetic::InitCalibInfo() { void Synthetic::InitCalibInfo() {
if (calib_model_ == CalibrationModel::UNKNOW) { if (calib_model_ == CalibrationModel::PINHOLE) {
calib_model_ = CalibrationModel::PINHOLE; LOG(INFO) << "camera calib model: pinhole";
LOG(INFO) << "camera calib model: unknow";
// use default
} else {
if (calib_model_ == CalibrationModel::PINHOLE) {
LOG(INFO) << "camera calib model: pinhole";
} else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) {
LOG(INFO) << "camera calib model: kannala_brandt";
}
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));
#ifdef WITH_CAM_MODELS
} else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) {
LOG(INFO) << "camera calib model: 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));
#endif
} else {
calib_model_ = CalibrationModel::PINHOLE;
LOG(INFO) << "camera calib model: unknow ,use default pinhole data";
intr_left_ = getDefaultIntrinsics();
intr_right_ = getDefaultIntrinsics();
extr_ = getDefaultExtrinsics();
} }
} }
@ -110,16 +117,20 @@ Synthetic::~Synthetic() {
} }
} }
void Synthetic::NotifyImageParamsChanged() { void Synthetic::NotifyImageParamsChanged(bool is_from_dev) {
if (is_from_dev && calib_model_ == CalibrationModel::PINHOLE) {
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 (calib_model_ == CalibrationModel::KANNALA_BRANDT) { } else if (is_from_dev && 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(); void NotifyImageParamsChanged(bool is_from_dev = false);
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;