svo
Semi-Direct Visual Odometry
include/svo/reprojector.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_REPROJECTION_H_
00018 #define SVO_REPROJECTION_H_
00019 
00020 #include <svo/global.h>
00021 #include <svo/matcher.h>
00022 
00023 namespace vk {
00024 class AbstractCamera;
00025 }
00026 
00027 namespace svo {
00028 
00029 class Map;
00030 class Point;
00031 
00037 class Reprojector
00038 {
00039 public:
00040   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00041 
00043   struct Options {
00044     size_t max_n_kfs;   
00045     bool find_match_direct;
00046     Options()
00047     : max_n_kfs(10),
00048       find_match_direct(true)
00049     {}
00050   } options_;
00051 
00052   size_t n_matches_;
00053   size_t n_trials_;
00054 
00055   Reprojector(vk::AbstractCamera* cam, Map& map);
00056 
00057   ~Reprojector();
00058 
00061   void reprojectMap(
00062       FramePtr frame,
00063       std::vector< std::pair<FramePtr,std::size_t> >& overlap_kfs);
00064 
00065 private:
00066 
00069   struct Candidate {
00070     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00071     Point* pt;       
00072     Vector2d px;     
00073     Candidate(Point* pt, Vector2d& px) : pt(pt), px(px) {}
00074   };
00075   typedef std::list<Candidate, aligned_allocator<Candidate> > Cell;
00076   typedef std::vector<Cell*> CandidateGrid;
00077 
00079   struct Grid
00080   {
00081     CandidateGrid cells;
00082     vector<int> cell_order;
00083     int cell_size;
00084     int grid_n_cols;
00085     int grid_n_rows;
00086   };
00087 
00088   Grid grid_;
00089   Matcher matcher_;
00090   Map& map_;
00091 
00092   static bool pointQualityComparator(Candidate& lhs, Candidate& rhs);
00093   void initializeGrid(vk::AbstractCamera* cam);
00094   void resetGrid();
00095   bool reprojectCell(Cell& cell, FramePtr frame);
00096   bool reprojectPoint(FramePtr frame, Point* point);
00097 };
00098 
00099 } // namespace svo
00100 
00101 #endif // SVO_REPROJECTION_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines