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



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