Main MRPT website > C++ reference
MRPT logo

chessboard_camera_calib.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 
00029 #ifndef mrpt_vision_chessboard_camera_calib_H
00030 #define mrpt_vision_chessboard_camera_calib_H
00031 
00032 #include <mrpt/utils/CImage.h>
00033 
00034 #include <mrpt/vision/types.h>
00035 
00036 #include <mrpt/vision/link_pragmas.h>
00037 
00038 namespace mrpt
00039 {
00040         namespace vision
00041         {
00042                 using namespace mrpt::utils;
00043 
00044                 /** @name Chessboard calibration 
00045                     @{  */
00046 
00047                 /** 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).
00048                   */
00049                 struct VISION_IMPEXP TImageCalibData
00050                 {
00051                         CImage  img_original;     //!< This image will be automatically loaded from the file name passed to checkerBoardCameraCalibration
00052                         CImage  img_checkboard;   //!< At output, this will contain the detected checkerboard overprinted to the image.
00053                         CImage  img_rectified;    //!< At output, this will be the rectified image
00054                         std::vector<mrpt::utils::TPixelCoordf>  detected_corners; //!< At output, the detected corners (x,y) in pixel units.
00055                         mrpt::poses::CPose3D                    reconstructed_camera_pose;   //!< At output, the reconstructed pose of the camera.
00056                         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.
00057                         std::vector<TPixelCoordf>               projectedPoints_undistorted; //!< At output, like projectedPoints_distorted but for the undistorted image.
00058                 };
00059 
00060                 /**  A list of images, used in checkerBoardCameraCalibration
00061                   * \sa checkerBoardCameraCalibration
00062                   */
00063                 typedef std::map<std::string,TImageCalibData> TCalibrationImageList;
00064 
00065                 /** Performs a camera calibration (computation of projection and distortion parameters) from a sequence of captured images of a checkerboard.
00066                   * \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.
00067                   * \param check_size_x [IN] The number of squares in the checkerboard in the X direction.
00068                   * \param check_size_y [IN] The number of squares in the checkerboard in the Y direction.
00069                   * \param check_squares_length_X_meters [IN] The size of each square in the checkerboard, in meters, in the X axis.
00070                   * \param check_squares_length_Y_meters [IN] This will typically be equal to check_squares_length_X_meters.
00071                   * \param intrinsicParams [OUT] The 3x3 intrinsic parameters matrix. See http://www.mrpt.org/Camera_Parameters
00072                   * \param distortionParams [OUT] The 1x4 vector of distortion parameters: k1 k2 p1 p2. See http://www.mrpt.org/Camera_Parameters
00073                   * \param normalize_image [IN] Select OpenCV flag
00074                   * \param out_MSE  [OUT] If set to !=NULL, the mean square error of the reprojection will be stored here (in pixel units).
00075                   * \param skipDrawDetectedImgs [IN] Whether to skip the generation of the undistorted and detected images in each TImageCalibData
00076                   * \param useScaramuzzaAlternativeDetector [IN] Whether to use an alternative detector. See CImage::findChessboardCorners for more deatails and references.
00077                   * \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.
00078                   * \return false on any error (more info will be dumped to cout), or true on success.
00079                   * \sa CImage::findChessboardCorners
00080                   */
00081                 bool VISION_IMPEXP checkerBoardCameraCalibration(
00082                         TCalibrationImageList &images,
00083                         unsigned int  check_size_x,
00084                         unsigned int  check_size_y,
00085                         double        check_squares_length_X_meters,
00086                         double        check_squares_length_Y_meters,
00087                         mrpt::utils::TCamera   &out_camera_params,
00088                         bool            normalize_image = true,
00089                         double            *out_MSE = NULL,
00090                         bool               skipDrawDetectedImgs = false,
00091                         bool                       useScaramuzzaAlternativeDetector = false
00092                         );
00093 
00094                 /** Performs a camera calibration (computation of projection and distortion parameters) from a sequence of captured images of a checkerboard.
00095                   * \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.
00096                   * \param check_size_x [IN] The number of squares in the checkerboard in the X direction.
00097                   * \param check_size_y [IN] The number of squares in the checkerboard in the Y direction.
00098                   * \param check_squares_length_X_meters [IN] The size of each square in the checkerboard, in meters, in the X axis.
00099                   * \param check_squares_length_Y_meters [IN] This will typically be equal to check_squares_length_X_meters.
00100                   * \param intrinsicParams [OUT] The 3x3 intrinsic parameters matrix. See http://www.mrpt.org/Camera_Parameters
00101                   * \param distortionParams [OUT] The 1x4 vector of distortion parameters: k1 k2 p1 p2. See http://www.mrpt.org/Camera_Parameters
00102                   * \param normalize_image [IN] Select OpenCV flag
00103                   * \param out_MSE  [OUT] If set to !=NULL, the mean square error of the reprojection will be stored here (in pixel units).
00104                   * \param skipDrawDetectedImgs [IN] Whether to skip the generation of the undistorted and detected images in each TImageCalibData
00105                   * \param useScaramuzzaAlternativeDetector [IN] Whether to use an alternative detector. See CImage::findChessboardCorners for more deatails and references.
00106                   * \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.
00107                   * \return false on any error (more info will be dumped to cout), or true on success.
00108                   * \sa CImage::findChessboardCorners
00109                   */
00110                 bool VISION_IMPEXP checkerBoardCameraCalibration(
00111                         TCalibrationImageList &images,
00112                         unsigned int  check_size_x,
00113                         unsigned int  check_size_y,
00114                         double        check_squares_length_X_meters,
00115                         double        check_squares_length_Y_meters,
00116                         CMatrixDouble33                 &intrinsicParams,
00117                         std::vector<double>             &distortionParams,
00118                         bool            normalize_image = true,
00119                         double            *out_MSE = NULL,
00120                         bool               skipDrawDetectedImgs = false,
00121                         bool                       useScaramuzzaAlternativeDetector = false
00122                         );
00123 
00124                 /** @}  */
00125 
00126         }
00127 }
00128 
00129 
00130 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011