svo
Semi-Direct Visual Odometry
include/svo/point.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_POINT_H_
00018 #define SVO_POINT_H_
00019 
00020 #include <boost/noncopyable.hpp>
00021 #include <svo/global.h>
00022 
00023 namespace g2o {
00024   class VertexSBAPointXYZ;
00025 }
00026 typedef g2o::VertexSBAPointXYZ g2oPoint;
00027 
00028 namespace svo {
00029 
00030 class Feature;
00031 
00032 typedef Matrix<double, 2, 3> Matrix23d;
00033 
00035 class Point : boost::noncopyable
00036 {
00037 public:
00038 
00039   enum PointType {
00040     TYPE_DELETED,
00041     TYPE_CANDIDATE,
00042     TYPE_UNKNOWN,
00043     TYPE_GOOD
00044   };
00045 
00046   static int                  point_counter_;           
00047   int                         id_;                      
00048   Vector3d                    pos_;                     
00049   Vector3d                    normal_;                  
00050   Matrix3d                    normal_information_;      
00051   bool                        normal_set_;              
00052   list<Feature*>              obs_;                     
00053   size_t                      n_obs_;                   
00054   g2oPoint*                   v_pt_;                    
00055   int                         last_published_ts_;       
00056   int                         last_projected_kf_id_;    
00057   PointType                   type_;                    
00058   int                         n_failed_reproj_;         
00059   int                         n_succeeded_reproj_;      
00060   int                         last_structure_optim_;    
00061 
00062   Point(const Vector3d& pos);
00063   Point(const Vector3d& pos, Feature* ftr);
00064   ~Point();
00065 
00067   void addFrameRef(Feature* ftr);
00068 
00070   bool deleteFrameRef(Frame* frame);
00071 
00073   void initNormal();
00074 
00076   Feature* findFrameRef(Frame* frame);
00077 
00079   bool getCloseViewObs(const Vector3d& pos, Feature*& obs) const;
00080 
00082   inline size_t nRefs() const { return obs_.size(); }
00083 
00085   void optimize(const size_t n_iter);
00086 
00088   inline static void jacobian_xyz2uv(
00089       const Vector3d& p_in_f,
00090       const Matrix3d& R_f_w,
00091       Matrix23d& point_jac)
00092   {
00093     const double z_inv = 1.0/p_in_f[2];
00094     const double z_inv_sq = z_inv*z_inv;
00095     point_jac(0, 0) = z_inv;
00096     point_jac(0, 1) = 0.0;
00097     point_jac(0, 2) = -p_in_f[0] * z_inv_sq;
00098     point_jac(1, 0) = 0.0;
00099     point_jac(1, 1) = z_inv;
00100     point_jac(1, 2) = -p_in_f[1] * z_inv_sq;
00101     point_jac = - point_jac * R_f_w;
00102   }
00103 };
00104 
00105 } // namespace svo
00106 
00107 #endif // SVO_POINT_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines