Main MRPT website > C++ reference
MRPT logo
chessboard_stereo_camera_calib.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef mrpt_vision_chessboard_stereo_calib_H
11 #define mrpt_vision_chessboard_stereo_calib_H
12 
13 #include <mrpt/utils/CImage.h>
15 #include <mrpt/vision/types.h>
18 
19 namespace mrpt
20 {
21  namespace vision
22  {
23  using namespace mrpt::utils;
24 
25  /** \addtogroup chessboard_calib Chessboard calibration
26  * \ingroup mrpt_vision_grp
27  * @{ */
28 
29  /** 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).
30  */
32  {
34 
35  /** Empty all the data */
36  void clear() { *this = TImageStereoCalibData(); }
37  };
38 
39  /** Params of the optional callback provided by the user */
41  {
42  int calibRound; //!< =-1:Processing images; =0: Initial calib without distortion, =1: Calib of all parameters
43  size_t current_iter;
44  double current_rmse; //!< Current root-mean square reprojection error (in pixels)
45  unsigned int nImgsProcessed, nImgsToProcess; //!< Info for calibRound==-1
46  };
47 
48  /** Prototype of optional user callback function. */
49  typedef void (*TSteroCalibCallbackFunctor)(const TImageStereoCallbackData &d, void* user_data);
50 
51 
52  /** Input parameters for mrpt::vision::checkerBoardStereoCalibration */
54  {
55  unsigned int check_size_x,check_size_y; //!< The number of squares in the checkerboard in the "X" & "Y" direction.
56  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.
59  bool verbose; //!< Show progress messages to std::cout console (default=true)
60  size_t maxIters; //!< Maximum number of iterations of the optimizer (default=300)
61 
62  /** Select which distortion parameters (of both left/right cameras) will be optimzed:
63  * 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).
64  * Those set to false will be assumed to be fixed to zero (no distortion).
65  * \note Default values are to only assume distortion via k1 and k2 (the rest are zeros).
66  */
67  bool optimize_k1, optimize_k2, optimize_k3, optimize_t1, optimize_t2;
68 
69  bool use_robust_kernel; //!< Employ a Pseudo-Huber robustifier kernel (Default: false)
70  double robust_kernel_param; //!< The parameter of the robust kernel, in pixels (only if use_robust_kernel=true) (Default=10)
71 
72 
73  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)
74  void * callback_user_param; //!< If using a callback function, you can use this to pass custom data to your callback.
75 
76  // Ctor: Set default values
78  };
79 
80  /** Output results for mrpt::vision::checkerBoardStereoCalibration */
82  {
84 
85  mrpt::utils::TStereoCamera cam_params; //!< Recovered parameters of the stereo camera
86  mrpt::poses::CPose3D right2left_camera_pose; //!< The pose of the left camera as seen from the right camera
87 
88  /** 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)
89  */
91  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.
92 
93  double final_rmse; //!< Final reprojection square Root Mean Square Error (in pixels).
94  size_t final_iters; //!< Final number of optimization iterations executed.
95  size_t final_number_good_image_pairs; //!< Number of image pairs in which valid checkerboards were correctly detected.
96 
97  /** The inverse variance (information/precision) of each of the 9 left/right camera parameters [fx fy cx cy k1 k2 k3 t1 t2].
98  * Those not estimated as indicated in TStereoCalibParams will be zeros (i.e. an "infinite uncertainty")
99  */
100  Eigen::Array<double,9,1> left_params_inv_variance, right_params_inv_variance;
101  };
102 
103  /** A list of images, used in checkerBoardStereoCalibration
104  * \sa checkerBoardStereoCalibration
105  */
106  typedef std::vector<TImageStereoCalibData> TCalibrationStereoImageList;
107 
108  /** Optimize the calibration parameters of a stereo camera or a RGB+D (Kinect) camera.
109  * This computes the projection and distortion parameters of each camera, and their relative spatial pose,
110  * from a sequence of pairs of captured images of a checkerboard.
111  * A custom implementation of an optimizer (Levenberg-Marquartd) seeks for the set of selected parameters to estimate that minimize the reprojection errors.
112  *
113  * \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.
114  * \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.
115  * \param out_results [OUT] The results of the calibration, and its uncertainty measure, will be found here upon return.
116  *
117  * \return false on any error (more info will be dumped to cout), or true on success.
118  * \note See also the ready-to-use application: <a href="http://www.mrpt.org/Application:kinect-calibrate" >kinect-calibrate</a>
119  * \sa CImage::findChessboardCorners, checkerBoardCameraCalibration, mrpt::hwdrivers::CKinect
120  */
122  TCalibrationStereoImageList & images,
123  const TStereoCalibParams & params,
124  TStereoCalibResults & out_results
125  );
126 
127  /** @} */ // end of grouping
128 
129  }
130 }
131 
132 
133 #endif
double final_rmse
Final reprojection square Root Mean Square Error (in pixels).
std::vector< TImageStereoCalibData > TCalibrationStereoImageList
A list of images, used in checkerBoardStereoCalibration.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
mrpt::utils::TStereoCamera cam_params
Recovered parameters of the stereo camera.
std::vector< bool > image_pair_was_used
true if a checkerboard was correctly detected in both left/right images. false if it wasn't...
unsigned int nImgsToProcess
Info for calibRound==-1.
void * callback_user_param
If using a callback function, you can use this to pass custom data to your callback.
size_t final_number_good_image_pairs
Number of image pairs in which valid checkerboards were correctly detected.
Data associated to each stereo image in the calibration process mrpt::vision::checkerBoardCameraCalib...
size_t maxIters
Maximum number of iterations of the optimizer (default=300)
unsigned int check_size_y
The number of squares in the checkerboard in the "X" & "Y" direction.
size_t final_iters
Final number of optimization iterations executed.
TSteroCalibCallbackFunctor callback
If set to !=NULL, this function will be called within each Lev-Marq. iteration (don't do heavy stuff ...
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:25
Data associated to each image in the calibration process mrpt::vision::checkerBoardCameraCalibration ...
Eigen::Array< double, 9, 1 > right_params_inv_variance
Input parameters for mrpt::vision::checkerBoardStereoCalibration.
mrpt::aligned_containers< mrpt::poses::CPose3D >::vector_t left_cam_poses
Poses of the origin of coordinates of the pattern wrt the left camera (i.e.
Params of the optional callback provided by the user.
bool VISION_IMPEXP checkerBoardStereoCalibration(TCalibrationStereoImageList &images, const TStereoCalibParams &params, TStereoCalibResults &out_results)
Optimize the calibration parameters of a stereo camera or a RGB+D (Kinect) camera.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void(* TSteroCalibCallbackFunctor)(const TImageStereoCallbackData &d, void *user_data)
Prototype of optional user callback function.
double current_rmse
Current root-mean square reprojection error (in pixels)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:69
mrpt::poses::CPose3D right2left_camera_pose
The pose of the left camera as seen from the right camera.
bool use_robust_kernel
Employ a Pseudo-Huber robustifier kernel (Default: false)
double check_squares_length_Y_meters
The size of each square in the checkerboard, in meters, in the "X" & "Y" axes.
bool verbose
Show progress messages to std::cout console (default=true)
double robust_kernel_param
The parameter of the robust kernel, in pixels (only if use_robust_kernel=true) (Default=10) ...
Output results for mrpt::vision::checkerBoardStereoCalibration.
int calibRound
=-1:Processing images; =0: Initial calib without distortion, =1: Calib of all parameters ...
std::vector< TYPE1, Eigen::aligned_allocator< TYPE1 > > vector_t



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014