Main MRPT website > C++ reference
MRPT logo
bundle_adjustment.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef mrpt_vision_ba_H
30 #define mrpt_vision_ba_H
31 
32 #include <mrpt/vision/types.h>
33 #include <mrpt/utils/TCamera.h>
34 #include <mrpt/utils/TParameters.h>
36 
37 // The methods declared in this file are implemented in separate files in: vision/src/ba_*.cpp
38 namespace mrpt
39 {
40  namespace vision
41  {
42  using mrpt::math::TPose3D;
45 
46  /** \defgroup bundle_adj Bundle-Adjustment methods
47  * \ingroup mrpt_vision_grp
48  */
49 
50 
51  /** @name Bundle-Adjustment methods
52  @{ */
53 
54  /** A functor type for BA methods \sa bundle_adj_full */
56  const size_t cur_iter,
57  const double cur_total_sq_error,
58  const size_t max_iters,
59  const mrpt::vision::TSequenceFeatureObservations & input_observations,
60  const mrpt::vision::TFramePosesVec & current_frame_estimate,
61  const mrpt::vision::TLandmarkLocationsVec & current_landmark_estimate );
62 
63 
64  /** Sparse Levenberg-Marquart solution to bundle adjustment - optimizes all the camera frames & the landmark locations.
65  * At input a gross estimation of the frame poses & the landmark points must be supplied. If you don't have such a
66  * starting point, use mrpt::vision::ba_initial_estimate() to compute it.
67  *
68  * At output the best found solution will be returned in the variables. Optionally, a functor can be passed for having
69  * feedback on the progress at each iteration (you can use it to refresh a GUI, display a progress bar, etc...).
70  *
71  * This implementation is almost entirely an adapted version from RobotVision (at OpenSLAM.org) (C) by Hauke Strasdat (Imperial College London), licensed under GNU LGPL.
72  * 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
73  *
74  * List of optional parameters in "extra_params":
75  * - "verbose" : Verbose output (default=0)
76  * - "max_iterations": Maximum number of iterations to run (default=50)
77  * - "robust_kernel": If !=0, use a robust kernel against outliers (default=1)
78  * - "kernel_param": The pseudo-huber kernel parameter (default=3)
79  * - "mu": Initial mu for LevMarq (default=-1 -> autoguess)
80  * - "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)
81  * - "num_fix_points": Idem, for the landmarks positions (default=0: optimize all)
82  * - "profiler": If !=0, displays profiling information to the console at return.
83  *
84  * \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).
85  * \note The first frame pose will be not updated since at least one frame must remain fixed.
86  *
87  * \param observations [IN] All the feature observations (WITHOUT distortion), indexed by feature ID as lists of <frame_ID, (x,y)>. See TSequenceFeatureObservations.
88  * \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.
89  * \param frame_poses [IN/OUT] Input: Gross estimation of each frame poses. Output: The found optimal solution.
90  * \param landmark_points [IN/OUT] Input: Gross estimation of each landmark point. Output: The found optimal solution.
91  * \param extra_params [IN] Optional extra parameters. Read above.
92  * \param user_feedback [IN] If provided, this functor will be called at each iteration to provide a feedback to the user.
93  *
94  * \return The final overall squared error.
95  * \ingroup bundle_adj
96  */
98  const mrpt::vision::TSequenceFeatureObservations & observations,
99  const mrpt::utils::TCamera & camera_params,
100  mrpt::vision::TFramePosesVec & frame_poses,
101  mrpt::vision::TLandmarkLocationsVec & landmark_points,
103  const mrpt::vision::TBundleAdjustmentFeedbackFunctor user_feedback = NULL
104  );
105 
106 
107  /** @} */
108 
109 
110  /** @name Bundle-Adjustment Auxiliary methods
111  @{ */
112 
113  /** 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.
114  * \sa bundle_adj_full
115  * \ingroup bundle_adj
116  */
118  const mrpt::vision::TSequenceFeatureObservations & observations,
119  const mrpt::utils::TCamera & camera_params,
120  mrpt::vision::TFramePosesVec & frame_poses,
121  mrpt::vision::TLandmarkLocationsVec & landmark_points );
122 
123  //! \overload
125  const mrpt::vision::TSequenceFeatureObservations & observations,
126  const mrpt::utils::TCamera & camera_params,
127  mrpt::vision::TFramePosesMap & frame_poses,
128  mrpt::vision::TLandmarkLocationsMap & landmark_points );
129 
130 
131  /** Compute reprojection error vector (used from within Bundle Adjustment methods, but can be used in general)
132  * See mrpt::vision::bundle_adj_full for a description of most parameters.
133  * \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.
134  *
135  * \return Overall squared reprojection error.
136  * \ingroup bundle_adj
137  */
139  const mrpt::vision::TSequenceFeatureObservations & observations,
140  const mrpt::utils::TCamera & camera_params,
141  const mrpt::vision::TFramePosesVec & frame_poses,
142  const mrpt::vision::TLandmarkLocationsVec & landmark_points,
143  std::vector<CArray<double,2> > & out_residuals,
144  const bool frame_poses_are_inverse,
145  const bool use_robust_kernel = true,
146  const double kernel_param = 3.0,
147  std::vector<double> * out_kernel_1st_deriv = NULL
148  );
149 
150  //! \overload
152  const mrpt::vision::TSequenceFeatureObservations & observations,
153  const mrpt::utils::TCamera & camera_params,
154  const mrpt::vision::TFramePosesMap & frame_poses,
155  const mrpt::vision::TLandmarkLocationsMap & landmark_points,
156  std::vector<CArray<double,2> > & out_residuals,
157  const bool frame_poses_are_inverse,
158  const bool use_robust_kernel = true,
159  const double kernel_param = 3.0,
160  std::vector<double> * out_kernel_1st_deriv = NULL
161  );
162 
163 
164  /** 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:
165  *
166  * new_frame_poses[i] = frame_poses[i] [+] delta[(first_idx+6*i):(first_idx+6*i+5)] , for every pose in \a frame_poses
167  *
168  * With the left-multiplication convention of the manifold exp(delta) operator, that is:
169  *
170  * p <-- p [+] delta ==> p <-- exp(delta) * p
171  *
172  * \param delta_num_vals Used just for sanity check, must be equal to "frame_poses.size() * 6"
173  * \ingroup bundle_adj
174  */
176  const mrpt::vision::TFramePosesVec & frame_poses,
177  const mrpt::vector_double &delta,
178  const size_t delta_first_idx,
179  const size_t delta_num_vals,
180  mrpt::vision::TFramePosesVec & new_frame_poses,
181  const size_t num_fix_frames );
182 
183  /** 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:
184  *
185  * new_landmark_points[i] = landmark_points[i] + delta[(first_idx+3*i):(first_idx+3*i+2)] , for every pose in \a landmark_points
186  *
187  * \param delta_num_vals Used just for sanity check, must be equal to "landmark_points.size() * 3"
188  * \ingroup bundle_adj
189  */
191  const mrpt::vision::TLandmarkLocationsVec & landmark_points,
192  const mrpt::vector_double & delta,
193  const size_t delta_first_idx,
194  const size_t delta_num_vals,
195  mrpt::vision::TLandmarkLocationsVec & new_landmark_points,
196  const size_t num_fix_points );
197 
198  /** @} */
199  }
200 }
201 #endif
202 



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013