00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 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 #ifndef mrpt_CUndistortMap_H 00029 #define mrpt_CUndistortMap_H 00030 00031 #include <mrpt/utils/TCamera.h> 00032 #include <mrpt/utils/CImage.h> 00033 00034 #include <mrpt/vision/link_pragmas.h> 00035 00036 namespace mrpt 00037 { 00038 namespace vision 00039 { 00040 /** Use this class to undistort images if the same distortion map is used over and over again. 00041 * Using this class is much more efficient that calling mrpt::utils::CImage::rectifyImage or OpenCV's cvUndistort2(), since 00042 * the remapping data is computed only once for the camera parameters (typical times: 640x480 image -> 70% build map / 30% actual undistort). 00043 * 00044 * Works with grayscale or color images. 00045 * 00046 * Example of usage: 00047 * \code 00048 * CUndistortMap unmap; 00049 * mrpt::utils::TCamera cam_params; 00050 * 00051 * unmap.setFromCamParams( cam_params ); 00052 * 00053 * mrpt::utils::CImage img, img_out; 00054 * 00055 * while (true) { 00056 * unmap.undistort(img, img_out); // or: 00057 * unmap.undistort(img); // output in place 00058 * } 00059 * 00060 * \endcode 00061 * 00062 * \sa mrpt::utils::TCamera, the application <a href="http://www.mrpt.org/Application:camera-calib" >camera-calib</a> for calibrating a camera. 00063 * \ingroup mrpt_vision_grp 00064 */ 00065 class VISION_IMPEXP CUndistortMap 00066 { 00067 public: 00068 CUndistortMap(); //!< Default ctor 00069 00070 /** Prepares the mapping from the distortion parameters of a camera. 00071 * Must be called before invoking \a undistort(). 00072 */ 00073 void setFromCamParams(const mrpt::utils::TCamera ¶ms); 00074 00075 /** Undistort the input image and saves the result in the output one - \a setFromCamParams() must have been set prior to calling this. 00076 */ 00077 void undistort(const mrpt::utils::CImage &in_img, mrpt::utils::CImage &out_img) const; 00078 00079 /** Undistort the input image and saves the result in-place- \a setFromCamParams() must have been set prior to calling this. 00080 */ 00081 void undistort(mrpt::utils::CImage &in_out_img) const; 00082 00083 /** Returns the camera parameters which were used to generate the distortion map, as passed by the user to \a setFromCamParams */ 00084 inline const mrpt::utils::TCamera & getCameraParams() const { return m_camera_params; } 00085 00086 /** Returns true if \a setFromCamParams() has been already called, false otherwise. 00087 * Can be used within loops to determine the first usage of the object and when it needs to be initialized. 00088 */ 00089 inline bool isSet() const { return !m_dat_mapx.empty(); } 00090 00091 private: 00092 std::vector<int16_t> m_dat_mapx; 00093 std::vector<uint16_t> m_dat_mapy; 00094 00095 mrpt::utils::TCamera m_camera_params; //!< A copy of the data provided by the user 00096 00097 }; // end class 00098 } // end namespace 00099 } // end namespace 00100 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |