SRBA: Sparser Relative Bundle Adjustment
|
00001 /* +---------------------------------------------------------------------------+ 00002 | Mobile Robot Programming Toolkit (MRPT) | 00003 | http://www.mrpt.org/ | 00004 | | 00005 | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file | 00006 | See: http://www.mrpt.org/Authors - All rights reserved. | 00007 | Released under BSD License. See details in http://www.mrpt.org/License | 00008 +---------------------------------------------------------------------------+ */ 00009 00010 #pragma once 00011 00012 namespace srba { 00013 00014 template <class KF2KF_POSE_TYPE,class LM_TYPE,class OBS_TYPE,class RBA_OPTIONS> 00015 void RbaEngine<KF2KF_POSE_TYPE,LM_TYPE,OBS_TYPE,RBA_OPTIONS>::optimize_local_area( 00016 const TKeyFrameID root_id, 00017 const unsigned int win_size, 00018 TOptimizeExtraOutputInfo & out_info, 00019 const TOptimizeLocalAreaParams ¶ms, 00020 const std::vector<size_t> & observation_indices_to_optimize 00021 ) 00022 { 00023 m_profiler.enter("optimize_local_area"); 00024 00025 // Use prebuilt spanning trees if possible (should be always!) 00026 const bool use_prebuilt_st = (win_size<= parameters.srba.max_tree_depth); 00027 if (!use_prebuilt_st) 00028 { 00029 VERBOSE_LEVEL(1) << "[optimize_local_area] *WARNING* Optimize win_size > max_tree_depth of prebuilt spanning trees. This is not efficient!\n"; 00030 } 00031 00032 // 1st) Find list of edges to optimize: 00033 // -------------------------------------------------- 00034 m_profiler.enter("optimize_local_area.find_edges2opt"); 00035 00036 VisitorOptimizeLocalArea my_visitor(this->rba_state,params); 00037 00038 this->bfs_visitor( 00039 root_id, // Starting keyframe 00040 win_size, // max. depth 00041 use_prebuilt_st, // Use prebuilt spanning trees for speed-up 00042 my_visitor, //kf_visitor, 00043 my_visitor, //feat_visitor, 00044 my_visitor, //k2k_edge_visitor, 00045 my_visitor //k2f_edge_visitor 00046 ); 00047 00048 m_profiler.leave("optimize_local_area.find_edges2opt"); 00049 00050 // 2nd) Optimize them: 00051 // ------------------------------- 00052 if (!my_visitor.k2k_edges_to_optimize.empty() || !my_visitor.lm_IDs_to_optimize.empty()) 00053 { 00054 this->optimize_edges(my_visitor.k2k_edges_to_optimize,my_visitor.lm_IDs_to_optimize, out_info, observation_indices_to_optimize); 00055 } 00056 00057 m_profiler.leave("optimize_local_area"); 00058 } 00059 00060 00061 00062 } // end NS