Class CUndistortMap
Defined in File CUndistortMap.h
Class Documentation
-
class CUndistortMap
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:
CUndistortMap unmap; mrpt::img::TCamera cam_params; unmap.setFromCamParams( cam_params ); mrpt::img::CImage img, img_out; 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.
Public Functions
-
CUndistortMap() = default
Default ctor
-
void setFromCamParams(const mrpt::img::TCamera ¶ms)
Prepares the mapping from the distortion parameters of a camera. Must be called before invoking 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 set prior to calling this.
-
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.
-
inline 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
-
inline bool isSet() const
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.
-
CUndistortMap() = default