Main MRPT website > C++ reference
MRPT logo
chessboard_camera_calib.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef mrpt_vision_chessboard_camera_calib_H
30 #define mrpt_vision_chessboard_camera_calib_H
31 
32 #include <mrpt/utils/CImage.h>
33 
34 #include <mrpt/vision/types.h>
35 
37 
38 namespace mrpt
39 {
40  namespace vision
41  {
42  using namespace mrpt::utils;
43 
44  /** \addtogroup chessboard_calib Chessboard calibration
45  * \ingroup mrpt_vision_grp
46  * @{ */
47 
48  /** Data associated to each image in the calibration process mrpt::vision::checkerBoardCameraCalibration (All the information can be left empty and will be filled up in the calibration method).
49  */
51  {
52  CImage img_original; //!< This image will be automatically loaded from the file name passed to checkerBoardCameraCalibration
53  CImage img_checkboard; //!< At output, this will contain the detected checkerboard overprinted to the image.
54  CImage img_rectified; //!< At output, this will be the rectified image
55  std::vector<mrpt::utils::TPixelCoordf> detected_corners; //!< At output, the detected corners (x,y) in pixel units.
56  mrpt::poses::CPose3D reconstructed_camera_pose; //!< At output, the reconstructed pose of the camera.
57  std::vector<TPixelCoordf> projectedPoints_distorted; //!< At output, only will have an empty vector if the checkerboard was not found in this image, or the predicted (reprojected) corners, which were used to estimate the average square error.
58  std::vector<TPixelCoordf> projectedPoints_undistorted; //!< At output, like projectedPoints_distorted but for the undistorted image.
59 
60  /** Empty all the data */
61  void clear() { *this = TImageCalibData(); }
62  };
63 
64  /** A list of images, used in checkerBoardCameraCalibration
65  * \sa checkerBoardCameraCalibration
66  */
67  typedef std::map<std::string,TImageCalibData> TCalibrationImageList;
68 
69  /** Performs a camera calibration (computation of projection and distortion parameters) from a sequence of captured images of a checkerboard.
70  * \param input_images [IN/OUT] At input, this list must have one entry for each image to process. At output the original, detected checkboard and rectified images can be found here. See TImageCalibData.
71  * \param check_size_x [IN] The number of squares in the checkerboard in the X direction.
72  * \param check_size_y [IN] The number of squares in the checkerboard in the Y direction.
73  * \param check_squares_length_X_meters [IN] The size of each square in the checkerboard, in meters, in the X axis.
74  * \param check_squares_length_Y_meters [IN] This will typically be equal to check_squares_length_X_meters.
75  * \param intrinsicParams [OUT] The 3x3 intrinsic parameters matrix. See http://www.mrpt.org/Camera_Parameters
76  * \param distortionParams [OUT] The 1x4 vector of distortion parameters: k1 k2 p1 p2. See http://www.mrpt.org/Camera_Parameters
77  * \param normalize_image [IN] Select OpenCV flag
78  * \param out_MSE [OUT] If set to !=NULL, the mean square error of the reprojection will be stored here (in pixel units).
79  * \param skipDrawDetectedImgs [IN] Whether to skip the generation of the undistorted and detected images in each TImageCalibData
80  * \param useScaramuzzaAlternativeDetector [IN] Whether to use an alternative detector. See CImage::findChessboardCorners for more deatails and references.
81  * \sa The <a href="http://www.mrpt.org/Application:camera-calib-gui" >camera-calib-gui application</a> is a user-friendly GUI to this class.
82  * \return false on any error (more info will be dumped to cout), or true on success.
83  * \sa CImage::findChessboardCorners, checkerBoardStereoCalibration
84  */
86  TCalibrationImageList &images,
87  unsigned int check_size_x,
88  unsigned int check_size_y,
89  double check_squares_length_X_meters,
90  double check_squares_length_Y_meters,
91  mrpt::utils::TCamera &out_camera_params,
92  bool normalize_image = true,
93  double *out_MSE = NULL,
94  bool skipDrawDetectedImgs = false,
95  bool useScaramuzzaAlternativeDetector = false
96  );
97 
98  /** Performs a camera calibration (computation of projection and distortion parameters) from a sequence of captured images of a checkerboard.
99  * \param input_images [IN/OUT] At input, this list must have one entry for each image to process. At output the original, detected checkboard and rectified images can be found here. See TImageCalibData.
100  * \param check_size_x [IN] The number of squares in the checkerboard in the X direction.
101  * \param check_size_y [IN] The number of squares in the checkerboard in the Y direction.
102  * \param check_squares_length_X_meters [IN] The size of each square in the checkerboard, in meters, in the X axis.
103  * \param check_squares_length_Y_meters [IN] This will typically be equal to check_squares_length_X_meters.
104  * \param intrinsicParams [OUT] The 3x3 intrinsic parameters matrix. See http://www.mrpt.org/Camera_Parameters
105  * \param distortionParams [OUT] The 1x4 vector of distortion parameters: k1 k2 p1 p2. See http://www.mrpt.org/Camera_Parameters
106  * \param normalize_image [IN] Select OpenCV flag
107  * \param out_MSE [OUT] If set to !=NULL, the mean square error of the reprojection will be stored here (in pixel units).
108  * \param skipDrawDetectedImgs [IN] Whether to skip the generation of the undistorted and detected images in each TImageCalibData
109  * \param useScaramuzzaAlternativeDetector [IN] Whether to use an alternative detector. See CImage::findChessboardCorners for more deatails and references.
110  * \sa The <a href="http://www.mrpt.org/Application:camera-calib-gui" >camera-calib-gui application</a> is a user-friendly GUI to this class.
111  * \return false on any error (more info will be dumped to cout), or true on success.
112  * \sa CImage::findChessboardCorners
113  */
115  TCalibrationImageList &images,
116  unsigned int check_size_x,
117  unsigned int check_size_y,
118  double check_squares_length_X_meters,
119  double check_squares_length_Y_meters,
120  CMatrixDouble33 &intrinsicParams,
121  std::vector<double> &distortionParams,
122  bool normalize_image = true,
123  double *out_MSE = NULL,
124  bool skipDrawDetectedImgs = false,
125  bool useScaramuzzaAlternativeDetector = false
126  );
127 
128  /** @} */ // end of grouping
129 
130  }
131 }
132 
133 
134 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013