Main MRPT website > C++ reference for MRPT 1.4.0
CUndistortMap.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef mrpt_CUndistortMap_H
10 #define mrpt_CUndistortMap_H
11 
12 #include <mrpt/utils/TCamera.h>
13 #include <mrpt/utils/CImage.h>
14 
16 
17 namespace mrpt
18 {
19  namespace vision
20  {
21  /** Use this class to undistort monocular images if the same distortion map is used over and over again.
22  * Using this class is much more efficient that calling mrpt::utils::CImage::rectifyImage or OpenCV's cvUndistort2(), since
23  * the remapping data is computed only once for the camera parameters (typical times: 640x480 image -> 70% build map / 30% actual undistort).
24  *
25  * Works with grayscale or color images.
26  *
27  * Example of usage:
28  * \code
29  * CUndistortMap unmap;
30  * mrpt::utils::TCamera cam_params;
31  *
32  * unmap.setFromCamParams( cam_params );
33  *
34  * mrpt::utils::CImage img, img_out;
35  *
36  * while (true) {
37  * unmap.undistort(img, img_out); // or:
38  * unmap.undistort(img); // output in place
39  * }
40  *
41  * \endcode
42  *
43  * \sa CStereoRectifyMap, mrpt::utils::TCamera, the application <a href="http://www.mrpt.org/Application:camera-calib" >camera-calib</a> for calibrating a camera.
44  * \ingroup mrpt_vision_grp
45  */
47  {
48  public:
49  CUndistortMap(); //!< Default ctor
50 
51  /** Prepares the mapping from the distortion parameters of a camera.
52  * Must be called before invoking \a undistort().
53  */
55 
56  /** Undistort the input image and saves the result in the output one - \a setFromCamParams() must have been set prior to calling this.
57  */
58  void undistort(const mrpt::utils::CImage &in_img, mrpt::utils::CImage &out_img) const;
59 
60  /** Undistort the input image and saves the result in-place- \a setFromCamParams() must have been set prior to calling this.
61  */
62  void undistort(mrpt::utils::CImage &in_out_img) const;
63 
64  /** Returns the camera parameters which were used to generate the distortion map, as passed by the user to \a setFromCamParams */
65  inline const mrpt::utils::TCamera & getCameraParams() const { return m_camera_params; }
66 
67  /** Returns true if \a setFromCamParams() has been already called, false otherwise.
68  * Can be used within loops to determine the first usage of the object and when it needs to be initialized.
69  */
70  inline bool isSet() const { return !m_dat_mapx.empty(); }
71 
72  private:
73  std::vector<int16_t> m_dat_mapx;
74  std::vector<uint16_t> m_dat_mapy;
75 
76  mrpt::utils::TCamera m_camera_params; //!< A copy of the data provided by the user
77 
78  }; // end class
79  } // end namespace
80 } // end namespace
81 #endif
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:102
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:32
Use this class to undistort monocular images if the same distortion map is used over and over again.
Definition: CUndistortMap.h:47
void setFromCamParams(const mrpt::utils::TCamera &params)
Prepares the mapping from the distortion parameters of a camera.
void undistort(const mrpt::utils::CImage &in_img, mrpt::utils::CImage &out_img) const
Undistort the input image and saves the result in the output one - setFromCamParams() must have been ...
void undistort(mrpt::utils::CImage &in_out_img) const
Undistort the input image and saves the result in-place- setFromCamParams() must have been set prior ...
std::vector< int16_t > m_dat_mapx
Definition: CUndistortMap.h:73
mrpt::utils::TCamera m_camera_params
A copy of the data provided by the user.
Definition: CUndistortMap.h:76
const mrpt::utils::TCamera & getCameraParams() const
Returns the camera parameters which were used to generate the distortion map, as passed by the user t...
Definition: CUndistortMap.h:65
std::vector< uint16_t > m_dat_mapy
Definition: CUndistortMap.h:74
bool isSet() const
Returns true if setFromCamParams() has been already called, false otherwise.
Definition: CUndistortMap.h:70
CUndistortMap()
Default ctor.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.1 for MRPT 1.4.0 SVN: at Sat Jan 30 21:34:41 UTC 2021