00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 00029 #ifndef mrpt_vision_ba_H 00030 #define mrpt_vision_ba_H 00031 00032 #include <mrpt/vision/types.h> 00033 #include <mrpt/utils/TCamera.h> 00034 #include <mrpt/utils/TParameters.h> 00035 #include <mrpt/math/lightweight_geom_data.h> 00036 00037 // The methods declared in this file are implemented in separate files in: vision/src/ba_*.cpp 00038 namespace mrpt 00039 { 00040 namespace vision 00041 { 00042 using mrpt::math::TPose3D; 00043 using mrpt::math::TPoint3D; 00044 using mrpt::utils::TCamera; 00045 00046 /** \defgroup bundle_adj Bundle-Adjustment methods 00047 * \ingroup mrpt_vision_grp 00048 */ 00049 00050 00051 /** @name Bundle-Adjustment methods 00052 @{ */ 00053 00054 /** A functor type for BA methods \sa bundle_adj_full */ 00055 typedef void (*TBundleAdjustmentFeedbackFunctor)( 00056 const size_t cur_iter, 00057 const double cur_total_sq_error, 00058 const size_t max_iters, 00059 const mrpt::vision::TSequenceFeatureObservations & input_observations, 00060 const mrpt::vision::TFramePosesVec & current_frame_estimate, 00061 const mrpt::vision::TLandmarkLocationsVec & current_landmark_estimate ); 00062 00063 00064 /** Sparse Levenberg-Marquart solution to bundle adjustment - optimizes all the camera frames & the landmark locations. 00065 * At input a gross estimation of the frame poses & the landmark points must be supplied. If you don't have such a 00066 * starting point, use mrpt::vision::ba_initial_estimate() to compute it. 00067 * 00068 * At output the best found solution will be returned in the variables. Optionally, a functor can be passed for having 00069 * feedback on the progress at each iteration (you can use it to refresh a GUI, display a progress bar, etc...). 00070 * 00071 * This implementation is almost entirely an adapted version from RobotVision (at OpenSLAM.org) (C) by Hauke Strasdat (Imperial College London), licensed under GNU LGPL. 00072 * See the related paper: H. Strasdat, J.M.M. Montiel, A.J. Davison: "Scale Drift-Aware Large Scale Monocular SLAM", RSS2010, http://www.roboticsproceedings.org/rss06/p10.html 00073 * 00074 * List of optional parameters in "extra_params": 00075 * - "verbose" : Verbose output (default=0) 00076 * - "max_iterations": Maximum number of iterations to run (default=50) 00077 * - "robust_kernel": If !=0, use a robust kernel against outliers (default=1) 00078 * - "kernel_param": The pseudo-huber kernel parameter (default=3) 00079 * - "mu": Initial mu for LevMarq (default=-1 -> autoguess) 00080 * - "num_fix_frames": Number of first frame poses to don't optimize (keep unmodified as they come in) (default=1: the first pose is the reference and is not modified) 00081 * - "num_fix_points": Idem, for the landmarks positions (default=0: optimize all) 00082 * - "profiler": If !=0, displays profiling information to the console at return. 00083 * 00084 * \note In this function, all coordinates are absolute. Camera frames are such that +Z points forward from the focal point (see the figure in mrpt::slam::CObservationImage). 00085 * \note The first frame pose will be not updated since at least one frame must remain fixed. 00086 * 00087 * \param observations [IN] All the feature observations (WITHOUT distortion), indexed by feature ID as lists of <frame_ID, (x,y)>. See TSequenceFeatureObservations. 00088 * \param camera_params [IN] The camera parameters, mainly used for the intrinsic 3x3 matrix. Distortion params are ignored since it's assumed that \a observations are already undistorted pixels. 00089 * \param frame_poses [IN/OUT] Input: Gross estimation of each frame poses. Output: The found optimal solution. 00090 * \param landmark_points [IN/OUT] Input: Gross estimation of each landmark point. Output: The found optimal solution. 00091 * \param extra_params [IN] Optional extra parameters. Read above. 00092 * \param user_feedback [IN] If provided, this functor will be called at each iteration to provide a feedback to the user. 00093 * 00094 * \return The final overall squared error. 00095 * \ingroup bundle_adj 00096 */ 00097 double VISION_IMPEXP bundle_adj_full( 00098 const mrpt::vision::TSequenceFeatureObservations & observations, 00099 const mrpt::utils::TCamera & camera_params, 00100 mrpt::vision::TFramePosesVec & frame_poses, 00101 mrpt::vision::TLandmarkLocationsVec & landmark_points, 00102 const mrpt::utils::TParametersDouble & extra_params = mrpt::utils::TParametersDouble(), 00103 const mrpt::vision::TBundleAdjustmentFeedbackFunctor user_feedback = NULL 00104 ); 00105 00106 00107 /** @} */ 00108 00109 00110 /** @name Bundle-Adjustment Auxiliary methods 00111 @{ */ 00112 00113 /** Fills the frames & landmark points maps with an initial gross estimate from the sequence \a observations, so they can be fed to bundle adjustment methods. 00114 * \sa bundle_adj_full 00115 * \ingroup bundle_adj 00116 */ 00117 void VISION_IMPEXP ba_initial_estimate( 00118 const mrpt::vision::TSequenceFeatureObservations & observations, 00119 const mrpt::utils::TCamera & camera_params, 00120 mrpt::vision::TFramePosesVec & frame_poses, 00121 mrpt::vision::TLandmarkLocationsVec & landmark_points ); 00122 00123 //! \overload 00124 void VISION_IMPEXP ba_initial_estimate( 00125 const mrpt::vision::TSequenceFeatureObservations & observations, 00126 const mrpt::utils::TCamera & camera_params, 00127 mrpt::vision::TFramePosesMap & frame_poses, 00128 mrpt::vision::TLandmarkLocationsMap & landmark_points ); 00129 00130 00131 /** Compute reprojection error vector (used from within Bundle Adjustment methods, but can be used in general) 00132 * See mrpt::vision::bundle_adj_full for a description of most parameters. 00133 * \param frame_poses_are_inverse If set to true, global camera poses are \f$ \ominus F \f$ instead of \f$ F \f$, for each F in frame_poses. 00134 * 00135 * \return Overall squared reprojection error. 00136 * \ingroup bundle_adj 00137 */ 00138 double VISION_IMPEXP reprojectionResiduals( 00139 const mrpt::vision::TSequenceFeatureObservations & observations, 00140 const mrpt::utils::TCamera & camera_params, 00141 const mrpt::vision::TFramePosesVec & frame_poses, 00142 const mrpt::vision::TLandmarkLocationsVec & landmark_points, 00143 std::vector<CArray<double,2> > & out_residuals, 00144 const bool frame_poses_are_inverse, 00145 const bool use_robust_kernel = true, 00146 const double kernel_param = 3.0 00147 ); 00148 00149 //! \overload 00150 double VISION_IMPEXP reprojectionResiduals( 00151 const mrpt::vision::TSequenceFeatureObservations & observations, 00152 const mrpt::utils::TCamera & camera_params, 00153 const mrpt::vision::TFramePosesMap & frame_poses, 00154 const mrpt::vision::TLandmarkLocationsMap & landmark_points, 00155 std::vector<CArray<double,2> > & out_residuals, 00156 const bool frame_poses_are_inverse, 00157 const bool use_robust_kernel = true, 00158 const double kernel_param = 3.0 00159 ); 00160 00161 00162 /** For each pose in the vector \a frame_poses, adds a "delta" increment to the manifold, with the "delta" given in the se(3) Lie algebra: 00163 * 00164 * new_frame_poses[i] = frame_poses[i] [+] delta[(first_idx+6*i):(first_idx+6*i+5)] , for every pose in \a frame_poses 00165 * 00166 * With the left-multiplication convention of the manifold exp(delta) operator, that is: 00167 * 00168 * p <-- p [+] delta ==> p <-- exp(delta) * p 00169 * 00170 * \param delta_num_vals Used just for sanity check, must be equal to "frame_poses.size() * 6" 00171 * \ingroup bundle_adj 00172 */ 00173 void VISION_IMPEXP add_se3_deltas_to_frames( 00174 const mrpt::vision::TFramePosesVec & frame_poses, 00175 const mrpt::vector_double &delta, 00176 const size_t delta_first_idx, 00177 const size_t delta_num_vals, 00178 mrpt::vision::TFramePosesVec & new_frame_poses, 00179 const size_t num_fix_frames ); 00180 00181 /** For each pose in the vector \a frame_poses, adds a "delta" increment to the manifold, with the "delta" given in the se(3) Lie algebra: 00182 * 00183 * new_landmark_points[i] = landmark_points[i] + delta[(first_idx+3*i):(first_idx+3*i+2)] , for every pose in \a landmark_points 00184 * 00185 * \param delta_num_vals Used just for sanity check, must be equal to "landmark_points.size() * 3" 00186 * \ingroup bundle_adj 00187 */ 00188 void VISION_IMPEXP add_3d_deltas_to_points( 00189 const mrpt::vision::TLandmarkLocationsVec & landmark_points, 00190 const mrpt::vector_double & delta, 00191 const size_t delta_first_idx, 00192 const size_t delta_num_vals, 00193 mrpt::vision::TLandmarkLocationsVec & new_landmark_points, 00194 const size_t num_fix_points ); 00195 00196 /** @} */ 00197 } 00198 } 00199 #endif 00200
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |