move depth filter ownership to frame handler mono

This commit is contained in:
Christian Forster
2014-03-31 21:44:31 +02:00
parent d0a2406041
commit 4c722969a9
4 changed files with 19 additions and 20 deletions
-4
View File
@@ -87,9 +87,6 @@ public:
/// Get the number of feature observations of the last frame. /// Get the number of feature observations of the last frame.
size_t lastNumObservations() const { return num_obs_last_; } size_t lastNumObservations() const { return num_obs_last_; }
/// Access the depth filter.
DepthFilter* depthFilter() const { return depth_filter_; }
protected: protected:
Stage stage_; //!< Current stage of the algorithm. Stage stage_; //!< Current stage of the algorithm.
bool set_reset_; //!< Flag that the user can set. Will reset the system before the next iteration. bool set_reset_; //!< Flag that the user can set. Will reset the system before the next iteration.
@@ -101,7 +98,6 @@ protected:
vk::RingBuffer<size_t> acc_num_obs_; //!< Number of observed features of the last 10 frames, used to give some user feedback on the tracking performance. vk::RingBuffer<size_t> acc_num_obs_; //!< Number of observed features of the last 10 frames, used to give some user feedback on the tracking performance.
size_t num_obs_last_; //!< Number of observations in the previous frame. size_t num_obs_last_; //!< Number of observations in the previous frame.
TrackingQuality tracking_quality_; //!< An estimate of the tracking quality based on the number of tracked features. TrackingQuality tracking_quality_; //!< An estimate of the tracking quality based on the number of tracked features.
DepthFilter* depth_filter_; //!< Depth estimation algorithm runs in a parallel thread and is used to initialize new 3D points.
/// Before a frame is processed, this function is called. /// Before a frame is processed, this function is called.
bool startFrameProcessingCommon(const double timestamp); bool startFrameProcessingCommon(const double timestamp);
+4
View File
@@ -47,6 +47,9 @@ public:
const vector<cv::Point2f>& initFeatureTrackRefPx() const { return klt_homography_init_.px_ref_; } const vector<cv::Point2f>& initFeatureTrackRefPx() const { return klt_homography_init_.px_ref_; }
const vector<cv::Point2f>& initFeatureTrackCurPx() const { return klt_homography_init_.px_cur_; } const vector<cv::Point2f>& initFeatureTrackCurPx() const { return klt_homography_init_.px_cur_; }
/// Access the depth filter.
DepthFilter* depthFilter() const { return depth_filter_; }
protected: protected:
vk::AbstractCamera* cam_; //!< Camera model, can be ATAN, Pinhole or Ocam (see vikit). vk::AbstractCamera* cam_; //!< Camera model, can be ATAN, Pinhole or Ocam (see vikit).
Reprojector reprojector_; //!< Projects points from other keyframes into the current frame Reprojector reprojector_; //!< Projects points from other keyframes into the current frame
@@ -55,6 +58,7 @@ protected:
set<FramePtr> core_kfs_; //!< Keyframes in the closer neighbourhood. set<FramePtr> core_kfs_; //!< Keyframes in the closer neighbourhood.
vector< pair<FramePtr,size_t> > overlap_kfs_; //!< All keyframes with overlapping field of view. the paired number specifies how many common mappoints are observed TODO: why vector!? vector< pair<FramePtr,size_t> > overlap_kfs_; //!< All keyframes with overlapping field of view. the paired number specifies how many common mappoints are observed TODO: why vector!?
initialization::KltHomographyInit klt_homography_init_; //!< Used to estimate pose of the first two keyframes by estimating a homography. 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.
/// Processes the first frame and sets it as a keyframe. /// Processes the first frame and sets it as a keyframe.
UpdateResult processFirstFrame(); UpdateResult processFirstFrame();
+1 -12
View File
@@ -25,7 +25,6 @@
#include <svo/matcher.h> #include <svo/matcher.h>
#include <svo/map.h> #include <svo/map.h>
#include <svo/point.h> #include <svo/point.h>
#include <svo/depth_filter.h>
namespace svo namespace svo
{ {
@@ -42,8 +41,7 @@ FrameHandlerBase::FrameHandlerBase() :
acc_frame_timings_(10), acc_frame_timings_(10),
acc_num_obs_(10), acc_num_obs_(10),
num_obs_last_(0), num_obs_last_(0),
tracking_quality_(TRACKING_BAD), tracking_quality_(TRACKING_BAD)
depth_filter_(NULL)
{ {
#ifdef SVO_TRACE #ifdef SVO_TRACE
// Initialize Performance Monitor // Initialize Performance Monitor
@@ -75,20 +73,12 @@ FrameHandlerBase::FrameHandlerBase() :
g_permon->init(Config::traceName(), Config::traceDir()); g_permon->init(Config::traceName(), Config::traceDir());
#endif #endif
// create depth filter and set callback
feature_detection::DetectorPtr feature_detector(new feature_detection::FastDetector());
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();
SVO_INFO_STREAM("NanoSlam initialized"); SVO_INFO_STREAM("NanoSlam initialized");
} }
FrameHandlerBase::~FrameHandlerBase() FrameHandlerBase::~FrameHandlerBase()
{ {
SVO_INFO_STREAM("SVO destructor invoked."); SVO_INFO_STREAM("SVO destructor invoked.");
delete depth_filter_;
SVO_INFO_STREAM("SVO destructed.");
} }
bool FrameHandlerBase::startFrameProcessingCommon(const double timestamp) bool FrameHandlerBase::startFrameProcessingCommon(const double timestamp)
@@ -149,7 +139,6 @@ void FrameHandlerBase::resetCommon()
set_reset_ = false; set_reset_ = false;
set_start_ = false; set_start_ = false;
tracking_quality_ = TRACKING_BAD; tracking_quality_ = TRACKING_BAD;
depth_filter_->reset();
num_obs_last_ = 0; num_obs_last_ = 0;
SVO_INFO_STREAM("RESET"); SVO_INFO_STREAM("RESET");
} }
+13 -3
View File
@@ -33,11 +33,20 @@ namespace svo {
FrameHandlerMono::FrameHandlerMono(vk::AbstractCamera* cam) : FrameHandlerMono::FrameHandlerMono(vk::AbstractCamera* cam) :
FrameHandlerBase(), FrameHandlerBase(),
cam_(cam), cam_(cam),
reprojector_(cam_, map_) reprojector_(cam_, map_),
{} depth_filter_(NULL)
{
// create depth filter and set callback
feature_detection::DetectorPtr feature_detector(new feature_detection::FastDetector());
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();
}
FrameHandlerMono::~FrameHandlerMono() FrameHandlerMono::~FrameHandlerMono()
{} {
delete depth_filter_;
}
void FrameHandlerMono::addImage(const cv::Mat& img, const double timestamp) void FrameHandlerMono::addImage(const cv::Mat& img, const double timestamp)
{ {
@@ -225,6 +234,7 @@ void FrameHandlerMono::resetAll()
new_frame_.reset(); new_frame_.reset();
core_kfs_.clear(); core_kfs_.clear();
overlap_kfs_.clear(); overlap_kfs_.clear();
depth_filter_->reset();
} }
bool FrameHandlerMono::needNewKf(double scene_depth_mean) bool FrameHandlerMono::needNewKf(double scene_depth_mean)