14 #include <mrpt/otherlibs/do_opencv_includes.h> 32 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM>=0x200 36 double aux1[3][3], aux2[1][5];
41 aux2[0][i]=campar.
dist[i];
43 const cv::Mat inMat( 3,3, CV_64F, aux1 );
44 const cv::Mat distM( 1, 5, CV_64F, aux2 );
52 cv::Mat _mapx = cv::cvarrToMat(&mapx,
false);
53 cv::Mat _mapy = cv::cvarrToMat(&mapy,
false);
55 cv::initUndistortRectifyMap( inMat, distM, cv::Mat(), inMat, _mapx.size(), _mapx.type(), _mapx, _mapy );
68 THROW_EXCEPTION(
"Error: setFromCamParams() must be called prior to undistort().")
70 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM>=0x200 74 const IplImage *srcImg = in_img.
getAs<IplImage>();
75 IplImage *outImg = cvCreateImage( cvGetSize( srcImg ), srcImg->depth, srcImg->nChannels );
76 cvRemap(srcImg, outImg, &mapx, &mapy);
88 THROW_EXCEPTION(
"Error: setFromCamParams() must be called prior to undistort().")
90 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM>=0x200 94 const IplImage *srcImg = in_out_img.
getAs<IplImage>();
95 IplImage *outImg = cvCreateImage( cvGetSize( srcImg ), srcImg->depth, srcImg->nChannels );
96 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
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...
uint32_t nrows
Camera resolution.
CUndistortMap()
Default ctor.
std::vector< int16_t > m_dat_mapx
Structure to hold the parameters of a pinhole camera model.