svo
Semi-Direct Visual Odometry
include/svo/sparse_img_align.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_SPARSE_IMG_ALIGN_H_
00018 #define SVO_SPARSE_IMG_ALIGN_H_
00019 
00020 #include <vikit/nlls_solver.h>
00021 #include <vikit/performance_monitor.h>
00022 #include <svo/global.h>
00023 
00024 namespace vk {
00025 class AbstractCamera;
00026 }
00027 
00028 namespace svo {
00029 
00030 class Feature;
00031 
00033 class SparseImgAlign : public vk::NLLSSolver<6, SE3>
00034 {
00035   static const int patch_halfsize_ = 2;
00036   static const int patch_size_ = 2*patch_halfsize_;
00037   static const int patch_area_ = patch_size_*patch_size_;
00038 public:
00039 
00040   cv::Mat resimg_;
00041 
00042   SparseImgAlign(
00043       int n_levels,
00044       int min_level,
00045       int n_iter,
00046       Method method,
00047       bool display,
00048       bool verbose);
00049 
00050   size_t run(
00051       FramePtr ref_frame,
00052       FramePtr cur_frame);
00053 
00056   Matrix<double, 6, 6> getFisherInformation();
00057 
00058 protected:
00059   FramePtr ref_frame_;            
00060   FramePtr cur_frame_;            
00061   int level_;                     
00062   bool display_;                  
00063   int max_level_;                 
00064   int min_level_;                 
00065 
00066   // cache:
00067   Matrix<double, 6, Dynamic, ColMajor> jacobian_cache_;
00068   bool have_ref_patch_cache_;
00069   cv::Mat ref_patch_cache_;
00070   std::vector<bool> visible_fts_;
00071 
00072   void precomputeReferencePatches();
00073   virtual double computeResiduals(const SE3& model, bool linearize_system, bool compute_weight_scale = false);
00074   virtual int solve();
00075   virtual void update (const ModelType& old_model, ModelType& new_model);
00076   virtual void startIteration();
00077   virtual void finishIteration();
00078 };
00079 
00080 } // namespace svo
00081 
00082 #endif // SVO_SPARSE_IMG_ALIGN_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines