MRPT
2.0.4
|
Use this class to undistort monocular images if the same distortion map is used over and over again.
Using this class is much more efficient that calling mrpt::img::CImage::rectifyImage or OpenCV's cvUndistort2(), since the remapping data is computed only once for the camera parameters (typical times: 640x480 image -> 70% build map / 30% actual undistort).
Works with grayscale or color images.
Example of usage:
Definition at line 46 of file CUndistortMap.h.
#include <mrpt/vision/CUndistortMap.h>
Public Member Functions | |
CUndistortMap () | |
Default ctor. More... | |
void | setFromCamParams (const mrpt::img::TCamera ¶ms) |
Prepares the mapping from the distortion parameters of a camera. More... | |
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 set prior to calling this. More... | |
void | undistort (mrpt::img::CImage &in_out_img) const |
Undistort the input image and saves the result in-place- setFromCamParams() must have been set prior to calling this. More... | |
const mrpt::img::TCamera & | getCameraParams () const |
Returns the camera parameters which were used to generate the distortion map, as passed by the user to setFromCamParams. More... | |
bool | isSet () const |
Returns true if setFromCamParams() has been already called, false otherwise. More... | |
Private Attributes | |
std::vector< int16_t > | m_dat_mapx |
std::vector< uint16_t > | m_dat_mapy |
mrpt::img::TCamera | m_camera_params |
A copy of the data provided by the user. More... | |
|
default |
Default ctor.
|
inline |
Returns the camera parameters which were used to generate the distortion map, as passed by the user to setFromCamParams.
Definition at line 70 of file CUndistortMap.h.
References m_camera_params.
|
inline |
Returns true if setFromCamParams() has been already called, false otherwise.
Can be used within loops to determine the first usage of the object and when it needs to be initialized.
Definition at line 80 of file CUndistortMap.h.
References m_dat_mapx.
void CUndistortMap::setFromCamParams | ( | const mrpt::img::TCamera & | campar | ) |
Prepares the mapping from the distortion parameters of a camera.
Must be called before invoking undistort().
Definition at line 26 of file CUndistortMap.cpp.
References mrpt::img::TCamera::dist, mrpt::img::TCamera::intrinsicParams, MRPT_END, MRPT_START, mrpt::img::TCamera::ncols, mrpt::img::TCamera::nrows, and THROW_EXCEPTION.
void CUndistortMap::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 set prior to calling this.
Undistort the input image and saves the result in-place- setFromCamParams() must have been set prior to calling this.
Definition at line 58 of file CUndistortMap.cpp.
References mrpt::img::CImage::asCvMat(), mrpt::img::CImage::getChannelCount(), mrpt::img::CImage::getHeight(), mrpt::img::CImage::getWidth(), MRPT_END, MRPT_START, mrpt::img::CImage::resize(), mrpt::img::SHALLOW_COPY, and THROW_EXCEPTION.
void CUndistortMap::undistort | ( | mrpt::img::CImage & | in_out_img | ) | const |
Undistort the input image and saves the result in-place- setFromCamParams() must have been set prior to calling this.
Definition at line 88 of file CUndistortMap.cpp.
References mrpt::img::CImage::asCvMat(), MRPT_END, MRPT_START, out, mrpt::img::SHALLOW_COPY, and THROW_EXCEPTION.
|
private |
A copy of the data provided by the user.
Definition at line 87 of file CUndistortMap.h.
Referenced by getCameraParams().
|
private |
Definition at line 83 of file CUndistortMap.h.
Referenced by isSet().
|
private |
Definition at line 84 of file CUndistortMap.h.
Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020 |