Use this class to undistort images if the same distortion map is used over and over again.
Using this class is much more efficient that calling mrpt::utils::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:
CUndistortMap unmap; mrpt::utils::TCamera cam_params; unmap.setFromCamParams( cam_params ); mrpt::utils::CImage img, img_out; while (true) { unmap.undistort(img, img_out); // or: unmap.undistort(img); // output in place }
Definition at line 62 of file CUndistortMap.h.
#include <mrpt/vision/CUndistortMap.h>
Public Member Functions | |
CUndistortMap () | |
Default ctor. | |
void | setFromCamParams (const mrpt::utils::TCamera ¶ms) |
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 set prior to calling this. | |
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 to calling this. | |
const mrpt::utils::TCamera & | getCameraParams () const |
Returns the camera parameters which were used to generate the distortion map, as passed by the user to setFromCamParams. | |
bool | isSet () const |
Returns true if setFromCamParams() has been already called, false otherwise. | |
Private Attributes | |
std::vector< int16_t > | m_dat_mapx |
std::vector< uint16_t > | m_dat_mapy |
mrpt::utils::TCamera | m_camera_params |
A copy of the data provided by the user. |
mrpt::vision::CUndistortMap::CUndistortMap | ( | ) |
Default ctor.
const mrpt::utils::TCamera& mrpt::vision::CUndistortMap::getCameraParams | ( | ) | const [inline] |
Returns the camera parameters which were used to generate the distortion map, as passed by the user to setFromCamParams.
Definition at line 81 of file CUndistortMap.h.
bool mrpt::vision::CUndistortMap::isSet | ( | ) | const [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 86 of file CUndistortMap.h.
void mrpt::vision::CUndistortMap::setFromCamParams | ( | const mrpt::utils::TCamera & | params | ) |
Prepares the mapping from the distortion parameters of a camera.
Must be called before invoking undistort().
void mrpt::vision::CUndistortMap::undistort | ( | mrpt::utils::CImage & | in_out_img | ) | const |
Undistort the input image and saves the result in-place- setFromCamParams() must have been set prior to calling this.
void mrpt::vision::CUndistortMap::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 set prior to calling this.
A copy of the data provided by the user.
Definition at line 92 of file CUndistortMap.h.
std::vector<int16_t> mrpt::vision::CUndistortMap::m_dat_mapx [private] |
Definition at line 89 of file CUndistortMap.h.
std::vector<uint16_t> mrpt::vision::CUndistortMap::m_dat_mapy [private] |
Definition at line 90 of file CUndistortMap.h.
Page generated by Doxygen 1.7.1 for MRPT 0.9.4 SVN: at Mon Jan 10 23:33:19 UTC 2011 |