Main MRPT website > C++ reference for MRPT 1.9.9
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-2017, 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 
15 namespace mrpt
16 {
17 namespace vision
18 {
19 /** Use this class to undistort monocular images if the same distortion map is
20  * used over and over again.
21  * Using this class is much more efficient that calling
22  * mrpt::utils::CImage::rectifyImage or OpenCV's cvUndistort2(), since
23  * the remapping data is computed only once for the camera parameters (typical
24  * times: 640x480 image -> 70% build map / 30% actual undistort).
25  *
26  * Works with grayscale or color images.
27  *
28  * Example of usage:
29  * \code
30  * CUndistortMap unmap;
31  * mrpt::utils::TCamera cam_params;
32  *
33  * unmap.setFromCamParams( cam_params );
34  *
35  * mrpt::utils::CImage img, img_out;
36  *
37  * while (true) {
38  * unmap.undistort(img, img_out); // or:
39  * unmap.undistort(img); // output in place
40  * }
41  *
42  * \endcode
43  *
44  * \sa CStereoRectifyMap, mrpt::utils::TCamera, the application <a
45  * href="http://www.mrpt.org/Application:camera-calib" >camera-calib</a> for
46  * calibrating a camera.
47  * \ingroup mrpt_vision_grp
48  */
50 {
51  public:
52  /** Default ctor */
53  CUndistortMap();
54 
55  /** Prepares the mapping from the distortion parameters of a camera.
56  * Must be called before invoking \a undistort().
57  */
59 
60  /** Undistort the input image and saves the result in the output one - \a
61  * setFromCamParams() must have been set prior to calling this.
62  */
63  void undistort(
64  const mrpt::utils::CImage& in_img, mrpt::utils::CImage& out_img) const;
65 
66  /** Undistort the input image and saves the result in-place- \a
67  * setFromCamParams() must have been set prior to calling this.
68  */
69  void undistort(mrpt::utils::CImage& in_out_img) const;
70 
71  /** Returns the camera parameters which were used to generate the distortion
72  * map, as passed by the user to \a setFromCamParams */
73  inline const mrpt::utils::TCamera& getCameraParams() const
74  {
75  return m_camera_params;
76  }
77 
78  /** Returns true if \a setFromCamParams() has been already called, false
79  * otherwise.
80  * Can be used within loops to determine the first usage of the object and
81  * when it needs to be initialized.
82  */
83  inline bool isSet() const { return !m_dat_mapx.empty(); }
84  private:
85  std::vector<int16_t> m_dat_mapx;
86  std::vector<uint16_t> m_dat_mapy;
87 
88  /** A copy of the data provided by the user */
90 
91 }; // end class
92 } // end namespace
93 } // end namespace
94 #endif
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 ...
mrpt::utils::TCamera m_camera_params
A copy of the data provided by the user.
Definition: CUndistortMap.h:89
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:118
bool isSet() const
Returns true if setFromCamParams() has been already called, false otherwise.
Definition: CUndistortMap.h:83
std::vector< uint16_t > m_dat_mapy
Definition: CUndistortMap.h:86
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:73
void setFromCamParams(const mrpt::utils::TCamera &params)
Prepares the mapping from the distortion parameters of a camera.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Use this class to undistort monocular images if the same distortion map is used over and over again...
Definition: CUndistortMap.h:49
GLenum const GLfloat * params
Definition: glext.h:3534
std::vector< int16_t > m_dat_mapx
Definition: CUndistortMap.h:85
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:32



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019