Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Private Attributes
mrpt::vision::CUndistortMap Class Reference

Detailed Description

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:

mrpt::img::TCamera cam_params;
unmap.setFromCamParams( cam_params );
while (true) {
unmap.undistort(img, img_out); // or:
unmap.undistort(img); // output in place
}
See also
CStereoRectifyMap, mrpt::img::TCamera, the application camera-calib for calibrating a camera.

Definition at line 49 of file CUndistortMap.h.

#include <mrpt/vision/CUndistortMap.h>

Public Member Functions

 CUndistortMap ()
 Default ctor. More...
 
void setFromCamParams (const mrpt::img::TCamera &params)
 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::TCameragetCameraParams () 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_tm_dat_mapx
 
std::vector< uint16_tm_dat_mapy
 
mrpt::img::TCamera m_camera_params
 A copy of the data provided by the user. More...
 

Constructor & Destructor Documentation

◆ CUndistortMap()

CUndistortMap::CUndistortMap ( )

Default ctor.

Definition at line 21 of file CUndistortMap.cpp.

Member Function Documentation

◆ getCameraParams()

const mrpt::img::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 73 of file CUndistortMap.h.

References m_camera_params.

◆ isSet()

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 83 of file CUndistortMap.h.

References m_dat_mapx.

◆ setFromCamParams()

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 25 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.

◆ undistort() [1/2]

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 61 of file CUndistortMap.cpp.

References mrpt::img::CImage::getAs(), MRPT_END, MRPT_START, mrpt::img::CImage::setFromIplImage(), and THROW_EXCEPTION.

◆ undistort() [2/2]

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 92 of file CUndistortMap.cpp.

References mrpt::img::CImage::getAs(), MRPT_END, MRPT_START, mrpt::img::CImage::setFromIplImage(), and THROW_EXCEPTION.

Member Data Documentation

◆ m_camera_params

mrpt::img::TCamera mrpt::vision::CUndistortMap::m_camera_params
private

A copy of the data provided by the user.

Definition at line 89 of file CUndistortMap.h.

Referenced by getCameraParams().

◆ m_dat_mapx

std::vector<int16_t> mrpt::vision::CUndistortMap::m_dat_mapx
private

Definition at line 85 of file CUndistortMap.h.

Referenced by isSet().

◆ m_dat_mapy

std::vector<uint16_t> mrpt::vision::CUndistortMap::m_dat_mapy
private

Definition at line 86 of file CUndistortMap.h.

mrpt::vision::CUndistortMap::CUndistortMap
CUndistortMap()
Default ctor.
Definition: CUndistortMap.cpp:21
mrpt::img::TCamera
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:29
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
img
GLint GLvoid * img
Definition: glext.h:3763



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