MRPT  2.0.1
chessboard_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/math/CMatrixFixed.h>
14 #include <mrpt/math/TPose3D.h>
15 #include <mrpt/poses/CPose3D.h>
16 #include <mrpt/vision/types.h>
17 
18 namespace mrpt::vision
19 {
20 /** \addtogroup chessboard_calib Chessboard calibration
21  * \ingroup mrpt_vision_grp
22  * @{ */
23 
24 /** Data associated to each 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 {
30  /** This image will be automatically loaded from the file name passed to
31  * checkerBoardCameraCalibration */
33  /** At output, this will contain the detected checkerboard overprinted to
34  * the image. */
36  /** At output, this will be the rectified image */
38  /** At output, the detected corners (x,y) in pixel units. */
39  std::vector<mrpt::img::TPixelCoordf> detected_corners;
40  /** At output, the reconstructed pose of the camera. */
42  /** At output, only will have an empty vector if the checkerboard was not
43  * found in this image, or the predicted (reprojected) corners, which were
44  * used to estimate the average square error. */
45  std::vector<mrpt::img::TPixelCoordf> projectedPoints_distorted;
46  /** At output, like projectedPoints_distorted but for the undistorted image.
47  */
48  std::vector<mrpt::img::TPixelCoordf> projectedPoints_undistorted;
49 
50  /** Empty all the data */
51  void clear() { *this = TImageCalibData(); }
52 };
53 
54 /** A list of images, used in checkerBoardCameraCalibration
55  * \sa checkerBoardCameraCalibration
56  */
57 using TCalibrationImageList = std::map<std::string, TImageCalibData>;
58 
59 /** Performs a camera calibration (computation of projection and distortion
60  * parameters) from a sequence of captured images of a checkerboard.
61  * \param input_images [IN/OUT] At input, this list must have one entry for
62  * each image to process. At output the original, detected checkboard and
63  * rectified images can be found here. See TImageCalibData.
64  * \param check_size_x [IN] The number of squares in the checkerboard in the X
65  * direction.
66  * \param check_size_y [IN] The number of squares in the checkerboard in the Y
67  * direction.
68  * \param check_squares_length_X_meters [IN] The size of each square in the
69  * checkerboard, in meters, in the X axis.
70  * \param check_squares_length_Y_meters [IN] This will typically be equal to
71  * check_squares_length_X_meters.
72  * \param intrinsicParams [OUT] The 3x3 intrinsic parameters matrix. See
73  * https://www.mrpt.org/Camera_Parameters
74  * \param distortionParams [OUT] The 1x4 vector of distortion parameters: k1 k2
75  * p1 p2. See https://www.mrpt.org/Camera_Parameters
76  * \param normalize_image [IN] Select OpenCV flag
77  * \param out_MSE [OUT] If set to !=nullptr, the mean square error of the
78  * reprojection will be stored here (in pixel units).
79  * \param skipDrawDetectedImgs [IN] Whether to skip the generation of the
80  * undistorted and detected images in each TImageCalibData
81  * \param useScaramuzzaAlternativeDetector [IN] Whether to use an alternative
82  * detector. See CImage::findChessboardCorners for more deatails and references.
83  * \sa The <a href="http://www.mrpt.org/Application:camera-calib-gui"
84  * >camera-calib-gui application</a> is a user-friendly GUI to this class.
85  * \return false on any error (more info will be dumped to cout), or true on
86  * success.
87  * \sa CImage::findChessboardCorners, checkerBoardStereoCalibration
88  */
91  unsigned int check_size_y, double check_squares_length_X_meters,
92  double check_squares_length_Y_meters, mrpt::img::TCamera& out_camera_params,
93  bool normalize_image = true, double* out_MSE = nullptr,
94  bool skipDrawDetectedImgs = false,
95  bool useScaramuzzaAlternativeDetector = false);
96 
97 /** \overload with matrix of intrinsic params instead of mrpt::img::TCamera
98  */
101  unsigned int check_size_y, double check_squares_length_X_meters,
103  mrpt::math::CMatrixDouble33& intrinsicParams,
104  std::vector<double>& distortionParams, bool normalize_image = true,
105  double* out_MSE = nullptr, bool skipDrawDetectedImgs = false,
106  bool useScaramuzzaAlternativeDetector = false);
107 
108 /** @} */ // end of grouping
109 } // namespace mrpt::vision
void clear()
Empty all the data.
mrpt::vision::TCalibrationStereoImageList images
std::map< std::string, TImageCalibData > TCalibrationImageList
A list of images, used in checkerBoardCameraCalibration.
bool checkerBoardCameraCalibration(TCalibrationImageList &images, unsigned int check_size_x, unsigned int check_size_y, double check_squares_length_X_meters, double check_squares_length_Y_meters, mrpt::img::TCamera &out_camera_params, bool normalize_image=true, double *out_MSE=nullptr, bool skipDrawDetectedImgs=false, bool useScaramuzzaAlternativeDetector=false)
Performs a camera calibration (computation of projection and distortion parameters) from a sequence o...
mrpt::img::CImage img_checkboard
At output, this will contain the detected checkerboard overprinted to the image.
Data associated to each image in the calibration process mrpt::vision::checkerBoardCameraCalibration ...
std::vector< mrpt::img::TPixelCoordf > detected_corners
At output, the detected corners (x,y) in pixel units.
Classes for computer vision, detectors, features, etc.
Definition: CDifodo.h:17
Parameters for the Brown-Conrady camera lens distortion model.
Definition: TCamera.h:26
std::vector< mrpt::img::TPixelCoordf > projectedPoints_undistorted
At output, like projectedPoints_distorted but for the undistorted image.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::poses::CPose3D reconstructed_camera_pose
At output, the reconstructed pose of the camera.
std::vector< mrpt::img::TPixelCoordf > projectedPoints_distorted
At output, only will have an empty vector if the checkerboard was not found in this image...
mrpt::img::CImage img_original
This image will be automatically loaded from the file name passed to checkerBoardCameraCalibration.
mrpt::img::CImage img_rectified
At output, this will be the rectified image.
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:148



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020