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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST