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