From 8291a6b9c170a94de386d9cd3f47c59777bc533d Mon Sep 17 00:00:00 2001 From: Christian Forster Date: Wed, 30 Apr 2014 12:41:01 +0200 Subject: [PATCH] FrameHandlerMono member functions are now virtual to allow specialization --- svo/include/svo/frame_handler_mono.h | 16 ++++++++++------ svo/src/frame_handler_mono.cpp | 12 +++++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/svo/include/svo/frame_handler_mono.h b/svo/include/svo/frame_handler_mono.h index 9024394..01f7b45 100644 --- a/svo/include/svo/frame_handler_mono.h +++ b/svo/include/svo/frame_handler_mono.h @@ -29,7 +29,7 @@ class FrameHandlerMono : public FrameHandlerBase { public: FrameHandlerMono(vk::AbstractCamera* cam); - ~FrameHandlerMono(); + virtual ~FrameHandlerMono(); /// Provide an image. void addImage(const cv::Mat& img, double timestamp); @@ -60,21 +60,25 @@ protected: initialization::KltHomographyInit klt_homography_init_; //!< Used to estimate pose of the first two keyframes by estimating a homography. DepthFilter* depth_filter_; //!< Depth estimation algorithm runs in a parallel thread and is used to initialize new 3D points. + /// Initialize the visual odometry algorithm. + virtual void initialize(); + /// Processes the first frame and sets it as a keyframe. - UpdateResult processFirstFrame(); + virtual UpdateResult processFirstFrame(); /// Processes all frames after the first frame until a keyframe is selected. - UpdateResult processSecondFrame(); + virtual UpdateResult processSecondFrame(); /// Processes all frames after the first two keyframes. - UpdateResult processFrame(); + virtual UpdateResult processFrame(); /// Reset the frame handler. Implement in derived class. virtual void resetAll(); - void setCoreKfs(size_t n_closest); + /// Keyframe selection criterion. + virtual bool needNewKf(double scene_depth_mean); - bool needNewKf(double scene_depth_mean); + void setCoreKfs(size_t n_closest); }; } // namespace svo diff --git a/svo/src/frame_handler_mono.cpp b/svo/src/frame_handler_mono.cpp index e588ce9..1e7bac5 100644 --- a/svo/src/frame_handler_mono.cpp +++ b/svo/src/frame_handler_mono.cpp @@ -36,10 +36,16 @@ FrameHandlerMono::FrameHandlerMono(vk::AbstractCamera* cam) : reprojector_(cam_, map_), depth_filter_(NULL) { - // create depth filter and set callback + initialize(); +} + +void FrameHandlerMono::initialize() +{ feature_detection::DetectorPtr feature_detector( - new feature_detection::FastDetector(cam_->width(), cam_->height(), Config::gridSize(), Config::nPyrLevels())); - DepthFilter::callback_t depth_filter_cb = boost::bind(&MapPointCandidates::newCandidatePoint, &map_.point_candidates_, _1, _2); + new feature_detection::FastDetector( + cam_->width(), cam_->height(), Config::gridSize(), Config::nPyrLevels())); + DepthFilter::callback_t depth_filter_cb = boost::bind( + &MapPointCandidates::newCandidatePoint, &map_.point_candidates_, _1, _2); depth_filter_ = new DepthFilter(feature_detector, depth_filter_cb); depth_filter_->startThread(); }