MRPT  2.0.0
chessboard_stereo_camera_calib.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/img/CImage.h>
13 #include <mrpt/img/TStereoCamera.h>
14 #include <mrpt/poses/CPose3D.h>
16 #include <mrpt/vision/types.h>
17 #include <array>
18 
19 namespace mrpt::vision
20 {
21 /** \addtogroup chessboard_calib Chessboard calibration
22  * \ingroup mrpt_vision_grp
23  * @{ */
24 
25 /** Data associated to each stereo image in the calibration process
26  * mrpt::vision::checkerBoardCameraCalibration (All the information can be left
27  * empty and will be filled up in the calibration method).
28  */
30 {
32 
33  /** Empty all the data */
34  void clear() { *this = TImageStereoCalibData(); }
35 };
36 
37 /** Params of the optional callback provided by the user */
39 {
40  /** =-1:Processing images; =0: Initial calib without distortion, =1: Calib
41  * of all parameters */
42  int calibRound{-1};
43  size_t current_iter{0};
44  /** Current root-mean square reprojection error (in pixels) */
45  double current_rmse{0};
46  /** Info for calibRound==-1 */
47  unsigned int nImgsProcessed{0}, nImgsToProcess{0};
48 };
49 
50 /** Prototype of optional user callback function. */
52  void (*)(const TImageStereoCallbackData& d, void* user_data);
53 
54 /** Input parameters for mrpt::vision::checkerBoardStereoCalibration */
56 {
57  /** The number of squares in the checkerboard in the "X" & "Y" direction. */
58  unsigned int check_size_x{7}, check_size_y{9};
59  /** The size of each square in the checkerboard, in meters, in the "X" & Y"
60  * axes. */
63  bool normalize_image{true};
64  bool skipDrawDetectedImgs{false};
65  /** Show progress messages to std::cout console (default=true) */
66  bool verbose{true};
67  /** Maximum number of iterations of the optimizer (default=300) */
68  size_t maxIters{2000};
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  */
79  bool optimize_k1{true}, optimize_k2{true}, optimize_k3{false},
80  optimize_t1{false}, optimize_t2{false};
81 
82  /** Employ a Pseudo-Huber robustifier kernel (Default: false) */
83  bool use_robust_kernel{false};
84  /** The parameter of the robust kernel, in pixels (only if
85  * use_robust_kernel=true) (Default=10) */
86  double robust_kernel_param{10};
87 
88  /** If set to !=NULL, this function will be called within each Lev-Marq.
89  * iteration (don't do heavy stuff here since performance will degrade) */
91  /** If using a callback function, you can use this to pass custom data to
92  * your callback. */
93  void* callback_user_param{nullptr};
94 
95  // Ctor: Set default values
97 };
98 
99 /** Output results for mrpt::vision::checkerBoardStereoCalibration */
101 {
103 
104  /** Recovered parameters of the stereo camera */
106  /** The pose of the left camera as seen from the right camera */
108 
109  /** Poses of the origin of coordinates of the pattern wrt the left camera
110  * (i.e. the origin of coordinates, as seen from the different camera poses)
111  */
112  std::vector<mrpt::math::TPose3D> left_cam_poses;
113  /** true if a checkerboard was correctly detected in both left/right images.
114  * false if it wasn't, so the image pair didn't make it to the optimization.
115  */
116  std::vector<bool> image_pair_was_used;
117 
118  /** Final reprojection square Root Mean Square Error (in pixels). */
119  double final_rmse{0};
120  /** Final number of optimization iterations executed. */
121  size_t final_iters{0};
122  /** Number of image pairs in which valid checkerboards were correctly
123  * detected. */
125 
126  /** The inverse variance (information/precision) of each of the 9 left/right
127  * camera parameters [fx fy cx cy k1 k2 k3 t1 t2].
128  * Those not estimated as indicated in TStereoCalibParams will be zeros
129  * (i.e. an "infinite uncertainty")
130  */
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 mrpt::vision
bool optimize_k1
Select which distortion parameters (of both left/right cameras) will be optimzed: k1...
double final_rmse
Final reprojection square Root Mean Square Error (in pixels).
mrpt::vision::TCalibrationStereoImageList images
std::vector< bool > image_pair_was_used
true if a checkerboard was correctly detected in both left/right images.
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)
mrpt::vision::TStereoCalibParams params
size_t final_iters
Final number of optimization iterations executed.
std::vector< mrpt::math::TPose3D > left_cam_poses
Poses of the origin of coordinates of the pattern wrt the left camera (i.e.
TSteroCalibCallbackFunctor callback
If set to !=NULL, this function will be called within each Lev-Marq.
double check_squares_length_X_meters
The size of each square in the checkerboard, in meters, in the "X" & Y" axes.
mrpt::img::TStereoCamera cam_params
Recovered parameters of the stereo camera.
Data associated to each image in the calibration process mrpt::vision::checkerBoardCameraCalibration ...
Input parameters for mrpt::vision::checkerBoardStereoCalibration.
Params of the optional callback provided by the user.
Classes for computer vision, detectors, features, etc.
Definition: CDifodo.h:17
void(*)(const TImageStereoCallbackData &d, void *user_data) TSteroCalibCallbackFunctor
Prototype of optional user callback function.
unsigned int check_size_x
The number of squares in the checkerboard in the "X" & "Y" direction.
bool checkerBoardStereoCalibration(TCalibrationStereoImageList &images, const TStereoCalibParams &params, TStereoCalibResults &out_results)
Optimize the calibration parameters of a stereo camera or a RGB+D (Kinect) camera.
double current_rmse
Current root-mean square reprojection error (in pixels)
unsigned int nImgsProcessed
Info for calibRound==-1.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
std::array< double, 9 > left_params_inv_variance
The inverse variance (information/precision) of each of the 9 left/right camera parameters [fx fy cx ...
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)
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 ...
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:23
std::vector< TImageStereoCalibData > TCalibrationStereoImageList
A list of images, used in checkerBoardStereoCalibration.



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020