14 #include <mrpt/otherlibs/do_opencv_includes.h> 27 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200 31 double aux1[3][3], aux2[1][5];
32 for (
int i = 0; i < 3; i++)
34 for (
int i = 0; i < 5; i++) aux2[0][i] = campar.
dist[i];
36 const cv::Mat inMat(3, 3, CV_64F, aux1);
37 const cv::Mat distM(1, 5, CV_64F, aux2);
45 cv::Mat _mapx = cv::cvarrToMat(&mapx,
false);
46 cv::Mat _mapy = cv::cvarrToMat(&mapy,
false);
48 cv::initUndistortRectifyMap(
49 inMat, distM, cv::Mat(), inMat, _mapx.size(), _mapx.type(), _mapx,
66 "Error: setFromCamParams() must be called prior to undistort().")
68 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200 77 const IplImage* srcImg = in_img.
getAs<IplImage>();
79 cvCreateImage(cvGetSize(srcImg), srcImg->depth, srcImg->nChannels);
80 cvRemap(srcImg, outImg, &mapx, &mapy);
96 "Error: setFromCamParams() must be called prior to undistort().")
98 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200 101 const_cast<int16_t*>(
107 const IplImage* srcImg = in_out_img.
getAs<IplImage>();
109 cvCreateImage(cvGetSize(srcImg), srcImg->depth, srcImg->nChannels);
110 cvRemap(srcImg, outImg, &mapx, &mapy);
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 ...
mrpt::utils::TCamera m_camera_params
A copy of the data provided by the user.
A class for storing images as grayscale or RGB bitmaps.
#define THROW_EXCEPTION(msg)
const T * getAs() const
Returns a pointer to a const T* containing the image - the idea is to call like "img.getAs<IplImage>()" so we can avoid here including OpenCV's headers.
std::vector< uint16_t > m_dat_mapy
uint32_t ncols
Camera resolution.
Classes for computer vision, detectors, features, etc.
void setFromIplImage(void *iplImage)
Reads the image from a OpenCV IplImage object (WITHOUT making a copy).
void setFromCamParams(const mrpt::utils::TCamera ¶ms)
Prepares the mapping from the distortion parameters of a camera.
mrpt::math::CMatrixDouble33 intrinsicParams
Matrix of intrinsic parameters (containing the focal length and principal point coordinates) ...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::math::CArrayDouble< 5 > dist
[k1 k2 t1 t2 k3] -> k_i: parameters of radial distortion, t_i: parameters of tangential distortion (d...
CUndistortMap()
Default ctor.
std::vector< int16_t > m_dat_mapx
Structure to hold the parameters of a pinhole camera model.