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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020