MRPT  1.9.9
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-2019, 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>
15 #include <mrpt/vision/types.h>
16 #include <array>
17 
18 namespace mrpt::vision
19 {
20 /** \addtogroup chessboard_calib Chessboard calibration
21  * \ingroup mrpt_vision_grp
22  * @{ */
23 
24 /** Data associated to each stereo image in the calibration process
25  * mrpt::vision::checkerBoardCameraCalibration (All the information can be left
26  * empty and will be filled up in the calibration method).
27  */
29 {
31 
32  /** Empty all the data */
33  void clear() { *this = TImageStereoCalibData(); }
34 };
35 
36 /** Params of the optional callback provided by the user */
38 {
39  /** =-1:Processing images; =0: Initial calib without distortion, =1: Calib
40  * of all parameters */
42  size_t current_iter;
43  /** Current root-mean square reprojection error (in pixels) */
44  double current_rmse;
45  /** Info for calibRound==-1 */
47 };
48 
49 /** Prototype of optional user callback function. */
51  void (*)(const TImageStereoCallbackData& d, void* user_data);
52 
53 /** Input parameters for mrpt::vision::checkerBoardStereoCalibration */
55 {
56  /** The number of squares in the checkerboard in the "X" & "Y" direction. */
57  unsigned int check_size_x{7}, check_size_y{9};
58  /** The size of each square in the checkerboard, in meters, in the "X" & Y"
59  * axes. */
62  bool normalize_image{true};
63  bool skipDrawDetectedImgs{false};
64  /** Show progress messages to std::cout console (default=true) */
65  bool verbose{true};
66  /** Maximum number of iterations of the optimizer (default=300) */
67  size_t maxIters{2000};
68 
69  /** Select which distortion parameters (of both left/right cameras) will be
70  * optimzed:
71  * k1,k2,k3 are the r^2, r^4 and r^6 radial distorion coeficients, and t1
72  * and t2 are the tangential distortion coeficients (see
73  * mrpt::img::TCamera).
74  * Those set to false will be assumed to be fixed to zero (no distortion).
75  * \note Default values are to only assume distortion via k1 and k2 (the
76  * rest are zeros).
77  */
78  bool optimize_k1{true}, optimize_k2{true}, optimize_k3{false},
79  optimize_t1{false}, optimize_t2{false};
80 
81  /** Employ a Pseudo-Huber robustifier kernel (Default: false) */
82  bool use_robust_kernel{false};
83  /** The parameter of the robust kernel, in pixels (only if
84  * use_robust_kernel=true) (Default=10) */
85  double robust_kernel_param{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. */
92  void* callback_user_param{nullptr};
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  */
111  std::vector<mrpt::poses::CPose3D> left_cam_poses;
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{0};
119  /** Final number of optimization iterations executed. */
120  size_t final_iters{0};
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  */
131 };
132 
133 /** A list of images, used in checkerBoardStereoCalibration
134  * \sa checkerBoardStereoCalibration
135  */
136 using TCalibrationStereoImageList = std::vector<TImageStereoCalibData>;
137 
138 /** Optimize the calibration parameters of a stereo camera or a RGB+D (Kinect)
139  * camera.
140  * This computes the projection and distortion parameters of each camera, and
141  * their relative spatial pose,
142  * from a sequence of pairs of captured images of a checkerboard.
143  * A custom implementation of an optimizer (Levenberg-Marquartd) seeks for the
144  * set of selected parameters to estimate that minimize the reprojection errors.
145  *
146  * \param input_images [IN/OUT] At input, this list must have one entry for
147  * each image to process. At output the original, detected checkboard and
148  * rectified images can be found here. See TImageCalibData.
149  * \param params [IN] Mandatory: the user must provide the size of the
150  * checkerboard, which parameters to optimize and which to leave fixed to zero,
151  * etc.
152  * \param out_results [OUT] The results of the calibration, and its
153  * uncertainty measure, will be found here upon return.
154  *
155  * \return false on any error (more info will be dumped to cout), or true on
156  * success.
157  * \note See also the ready-to-use application: <a
158  * href="http://www.mrpt.org/list-of-mrpt-apps/application-kinect-calibrate"
159  * >kinect-calibrate</a>
160  * \sa CImage::findChessboardCorners, checkerBoardCameraCalibration,
161  * mrpt::hwdrivers::CKinect
162  */
165  TStereoCalibResults& out_results);
166 
167 /** @} */ // end of grouping
168 } // 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).
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)
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.
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:84
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.
std::vector< mrpt::poses::CPose3D > left_cam_poses
Poses of the origin of coordinates of the pattern wrt the left camera (i.e.
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
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 ...
GLenum const GLfloat * params
Definition: glext.h:3538
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 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019