svo
Semi-Direct Visual Odometry
include/svo/feature_detection.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_FEATURE_DETECTION_H_
00018 #define SVO_FEATURE_DETECTION_H_
00019 
00020 #include <svo/global.h>
00021 #include <svo/frame.h>
00022 
00023 namespace svo {
00024 
00026 namespace feature_detection {
00027 
00029 struct Corner
00030 {
00031   int x;        
00032   int y;        
00033   int level;    
00034   float score;  
00035   float angle;  
00036   Corner(int x, int y, float score, int level, float angle) :
00037     x(x), y(y), level(level), score(score), angle(angle)
00038   {}
00039 };
00040 typedef vector<Corner> Corners;
00041 
00043 class AbstractDetector
00044 {
00045 public:
00046   AbstractDetector(
00047       const int img_width,
00048       const int img_height,
00049       const int cell_size,
00050       const int n_pyr_levels);
00051 
00052   virtual ~AbstractDetector() {};
00053 
00054   virtual void detect(
00055       Frame* frame,
00056       const ImgPyr& img_pyr,
00057       const double detection_threshold,
00058       Features& fts) = 0;
00059 
00061   void setGridOccpuancy(const Vector2d& px);
00062 
00064   void setExistingFeatures(const Features& fts);
00065 
00066 protected:
00067 
00068   static const int border_ = 8; 
00069   const int cell_size_;
00070   const int n_pyr_levels_;
00071   const int grid_n_cols_;
00072   const int grid_n_rows_;
00073   vector<bool> grid_occupancy_;
00074 
00075   void resetGrid();
00076 
00077   inline int getCellIndex(int x, int y, int level)
00078   {
00079     const int scale = (1<<level);
00080     return (scale*y)/cell_size_*grid_n_cols_ + (scale*x)/cell_size_;
00081   }
00082 };
00083 typedef boost::shared_ptr<AbstractDetector> DetectorPtr;
00084 
00086 class FastDetector : public AbstractDetector
00087 {
00088 public:
00089   FastDetector(
00090       const int img_width,
00091       const int img_height,
00092       const int cell_size,
00093       const int n_pyr_levels);
00094 
00095   virtual ~FastDetector() {}
00096 
00097   virtual void detect(
00098       Frame* frame,
00099       const ImgPyr& img_pyr,
00100       const double detection_threshold,
00101       Features& fts);
00102 };
00103 
00104 } // namespace feature_detection
00105 } // namespace svo
00106 
00107 #endif // SVO_FEATURE_DETECTION_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines