svo
Semi-Direct Visual Odometry
include/svo/frame_handler_base.h
Go to the documentation of this file.
00001 // This file is part of SVO - Semi-direct Visual Odometry.
00002 //
00003 // Copyright (C) 2014 Christian Forster <forster at ifi dot uzh dot ch>
00004 // (Robotics and Perception Group, University of Zurich, Switzerland).
00005 //
00006 // SVO is free software: you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the Free Software
00008 // Foundation, either version 3 of the License, or any later version.
00009 //
00010 // SVO is distributed in the hope that it will be useful, but WITHOUT ANY
00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef SVO_FRAME_HANDLER_BASE_H_
00018 #define SVO_FRAME_HANDLER_BASE_H_
00019 
00020 #include <queue>
00021 #include <vikit/timer.h>
00022 #include <vikit/ringbuffer.h>
00023 #include <boost/noncopyable.hpp>
00024 #include <boost/function.hpp>
00025 #include <boost/thread.hpp>
00026 #include <svo/global.h>
00027 #include <svo/map.h>
00028 
00029 namespace vk
00030 {
00031 class AbstractCamera;
00032 class PerformanceMonitor;
00033 }
00034 
00035 namespace svo
00036 {
00037 class Point;
00038 class Matcher;
00039 class DepthFilter;
00040 
00042 class FrameHandlerBase : boost::noncopyable
00043 {
00044 public:
00045   enum Stage {
00046     STAGE_PAUSED,
00047     STAGE_FIRST_FRAME,
00048     STAGE_SECOND_FRAME,
00049     STAGE_DEFAULT_FRAME,
00050     STAGE_RELOCALIZING
00051   };
00052   enum TrackingQuality {
00053     TRACKING_INSUFFICIENT,
00054     TRACKING_BAD,
00055     TRACKING_GOOD
00056   };
00057   enum UpdateResult {
00058     RESULT_NO_KEYFRAME,
00059     RESULT_IS_KEYFRAME,
00060     RESULT_FAILURE
00061   };
00062 
00063   FrameHandlerBase();
00064 
00065   virtual ~FrameHandlerBase();
00066 
00068   const Map& map() const { return map_; }
00069 
00071   void reset() { set_reset_ = true; }
00072 
00074   void start() { set_start_ = true; }
00075 
00077   Stage stage() const { return stage_; }
00078 
00080   TrackingQuality trackingQuality() const { return tracking_quality_; }
00081 
00083   double lastProcessingTime() const { return timer_.getTime(); }
00084 
00086   size_t lastNumObservations() const { return num_obs_last_; }
00087 
00088 protected:
00089   Stage stage_;                 
00090   bool set_reset_;              
00091   bool set_start_;              
00092   Map map_;                     
00093   vk::Timer timer_;             
00094   vk::RingBuffer<double> acc_frame_timings_;    
00095   vk::RingBuffer<size_t> acc_num_obs_;          
00096   size_t num_obs_last_;                         
00097   TrackingQuality tracking_quality_;            
00098 
00100   bool startFrameProcessingCommon(const double timestamp);
00101 
00103   int finishFrameProcessingCommon(
00104       const size_t update_id,
00105       const UpdateResult dropout,
00106       const size_t num_observations);
00107 
00109   void resetCommon();
00110 
00112   virtual void resetAll() { resetCommon(); }
00113 
00115   virtual void setTrackingQuality(const size_t num_observations);
00116 
00118   virtual void optimizeStructure(FramePtr frame, size_t max_n_pts, int max_iter);
00119 };
00120 
00121 } // namespace nslam
00122 
00123 #endif // SVO_FRAME_HANDLER_BASE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines