Main MRPT website > C++ reference
MRPT logo
chessboard_stereo_camera_calib.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_chessboard_stereo_calib_H
30 #define mrpt_vision_chessboard_stereo_calib_H
31 
32 #include <mrpt/utils/CImage.h>
34 #include <mrpt/vision/types.h>
37 
38 namespace mrpt
39 {
40  namespace vision
41  {
42  using namespace mrpt::utils;
43 
44  /** \addtogroup chessboard_calib Chessboard calibration
45  * \ingroup mrpt_vision_grp
46  * @{ */
47 
48  /** Data associated to each stereo image in the calibration process mrpt::vision::checkerBoardCameraCalibration (All the information can be left empty and will be filled up in the calibration method).
49  */
51  {
53 
54  /** Empty all the data */
55  void clear() { *this = TImageStereoCalibData(); }
56  };
57 
58  /** Params of the optional callback provided by the user */
60  {
61  int calibRound; //!< =0: Initial calib without distortion, =1: Calib of all parameters
62  size_t current_iter;
63  double current_rmse; //!< Current root-mean square reprojection error (in pixels)
64  };
65 
66  /** Prototype of optional user callback function. */
67  typedef void (*TSteroCalibCallbackFunctor)(const TImageStereoCallbackData &d, void* user_data);
68 
69 
70  /** Input parameters for mrpt::vision::checkerBoardStereoCalibration */
72  {
73  unsigned int check_size_x,check_size_y; //!< The number of squares in the checkerboard in the "X" & "Y" direction.
74  double check_squares_length_X_meters,check_squares_length_Y_meters; //!< The size of each square in the checkerboard, in meters, in the "X" & "Y" axes.
77  bool verbose; //!< Show progress messages to std::cout console (default=true)
78  size_t maxIters; //!< Maximum number of iterations of the optimizer (default=300)
79 
80  /** Select which distortion parameters (of both left/right cameras) will be optimzed:
81  * k1,k2,k3 are the r^2, r^4 and r^6 radial distorion coeficients, and t1 and t2 are the tangential distortion coeficients (see mrpt::utils::TCamera).
82  * Those set to false will be assumed to be fixed to zero (no distortion).
83  * \note Default values are to only assume distortion via k1 and k2 (the rest are zeros).
84  */
85  bool optimize_k1, optimize_k2, optimize_k3, optimize_t1, optimize_t2;
86 
87  bool use_robust_kernel; //!< Employ a Pseudo-Huber robustifier kernel (Default: false)
88  double robust_kernel_param; //!< The parameter of the robust kernel, in pixels (only if use_robust_kernel=true) (Default=10)
89 
90 
91  TSteroCalibCallbackFunctor callback; //!< If set to !=NULL, this function will be called within each Lev-Marq. iteration (don't do heavy stuff here since performance will degrade)
92  void * callback_user_param; //!< If using a callback function, you can use this to pass custom data to your callback.
93 
94  // Ctor: Set default values
96  };
97 
98  /** Output results for mrpt::vision::checkerBoardStereoCalibration */
100  {
102 
103  mrpt::utils::TStereoCamera cam_params; //!< Recovered parameters of the stereo camera
104  mrpt::poses::CPose3D right2left_camera_pose; //!< The pose of the left camera as seen from the right camera
105 
106  /** Poses of the origin of coordinates of the pattern wrt the left camera (i.e. the origin of coordinates, as seen from the different camera poses)
107  */
109  std::vector<bool> image_pair_was_used; //!< true if a checkerboard was correctly detected in both left/right images. false if it wasn't, so the image pair didn't make it to the optimization.
110 
111  double final_rmse; //!< Final reprojection square Root Mean Square Error (in pixels).
112  size_t final_iters; //!< Final number of optimization iterations executed.
113  size_t final_number_good_image_pairs; //!< Number of image pairs in which valid checkerboards were correctly detected.
114 
115  /** The inverse variance (information/precision) of each of the 9 left/right camera parameters [fx fy cx cy k1 k2 k3 t1 t2].
116  * Those not estimated as indicated in TStereoCalibParams will be zeros (i.e. an "infinite uncertainty")
117  */
118  Eigen::Array<double,9,1> left_params_inv_variance, right_params_inv_variance;
119  };
120 
121  /** A list of images, used in checkerBoardStereoCalibration
122  * \sa checkerBoardStereoCalibration
123  */
124  typedef std::vector<TImageStereoCalibData> TCalibrationStereoImageList;
125 
126  /** Optimize the calibration parameters of a stereo camera or a RGB+D (Kinect) camera.
127  * This computes the projection and distortion parameters of each camera, and their relative spatial pose,
128  * from a sequence of pairs of captured images of a checkerboard.
129  *
130  * \param input_images [IN/OUT] At input, this list must have one entry for each image to process. At output the original, detected checkboard and rectified images can be found here. See TImageCalibData.
131  * \param params [IN] Mandatory: the user must provide the size of the checkerboard, which parameters to optimize and which to leave fixed to zero, etc.
132  * \param out_results [OUT] The results of the calibration, and its uncertainty measure, will be found here upon return.
133  *
134  * \return false on any error (more info will be dumped to cout), or true on success.
135  * \note See also the ready-to-use application: <a href="http://www.mrpt.org/Application:kinect-calibrate" >kinect-calibrate</a>
136  * \sa CImage::findChessboardCorners, checkerBoardCameraCalibration, mrpt::hwdrivers::CKinect
137  */
140  const TStereoCalibParams & params,
141  TStereoCalibResults & out_results
142  );
143 
144  /** @} */ // end of grouping
145 
146  }
147 }
148 
149 
150 #endif



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