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-2018, 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/img/TCamera.h>
13 #include <mrpt/img/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::img::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::img::TCamera cam_params;
32  *
33  * unmap.setFromCamParams( cam_params );
34  *
35  * mrpt::img::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::img::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::img::CImage& in_img, mrpt::img::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::img::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::img::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
mrpt::vision::CUndistortMap::getCameraParams
const mrpt::img::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
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
TCamera.h
mrpt::vision::CUndistortMap::CUndistortMap
CUndistortMap()
Default ctor.
Definition: CUndistortMap.cpp:21
mrpt::vision::CUndistortMap::m_dat_mapx
std::vector< int16_t > m_dat_mapx
Definition: CUndistortMap.h:85
mrpt::img::TCamera
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:29
mrpt::vision::CUndistortMap::setFromCamParams
void setFromCamParams(const mrpt::img::TCamera &params)
Prepares the mapping from the distortion parameters of a camera.
Definition: CUndistortMap.cpp:25
mrpt::vision::CUndistortMap
Use this class to undistort monocular images if the same distortion map is used over and over again.
Definition: CUndistortMap.h:49
mrpt::vision::CUndistortMap::m_camera_params
mrpt::img::TCamera m_camera_params
A copy of the data provided by the user.
Definition: CUndistortMap.h:89
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
mrpt::vision::CUndistortMap::undistort
void undistort(const mrpt::img::CImage &in_img, mrpt::img::CImage &out_img) const
Undistort the input image and saves the result in the output one - setFromCamParams() must have been ...
Definition: CUndistortMap.cpp:61
mrpt::vision::CUndistortMap::m_dat_mapy
std::vector< uint16_t > m_dat_mapy
Definition: CUndistortMap.h:86
mrpt::vision::CUndistortMap::isSet
bool isSet() const
Returns true if setFromCamParams() has been already called, false otherwise.
Definition: CUndistortMap.h:83
CImage.h
params
GLenum const GLfloat * params
Definition: glext.h:3534



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST