Main MRPT website > C++ reference for MRPT 1.9.9
CStereoRectifyMap.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "vision-precomp.h" // Precompiled headers
12 
13 // Universal include for all versions of OpenCV
14 #include <mrpt/otherlibs/do_opencv_includes.h>
15 
16 using namespace mrpt;
17 using namespace mrpt::poses;
18 using namespace mrpt::vision;
19 using namespace mrpt::img;
20 using namespace mrpt::math;
21 
22 // Ctor: Leave all vectors empty
23 CStereoRectifyMap::CStereoRectifyMap()
24  : m_alpha(-1),
25  m_resize_output(false),
26  m_enable_both_centers_coincide(false),
27  m_resize_output_value(0, 0),
28  m_interpolation_method(mrpt::img::IMG_INTERP_LINEAR)
29 {
30 }
31 
33 {
35  .clear(); // don't do a "strong clear" since memory is likely
36  m_dat_mapx_right.clear(); // to be reasigned soon.
37  m_dat_mapy_left.clear();
38  m_dat_mapy_right.clear();
39 }
40 
42 {
43  m_alpha = alpha;
44 
45  this->internal_invalidate();
46 }
47 
49  bool enable, unsigned int target_width, unsigned int target_height)
50 {
51  m_resize_output = enable;
52  m_resize_output_value.x = target_width;
53  m_resize_output_value.y = target_height;
54 
55  this->internal_invalidate();
56 }
57 
59 {
61 
62  this->internal_invalidate();
63 }
64 
65 /** Prepares the mapping from the distortion parameters of a camera.
66  * Must be called before invoking \a undistort().
67  */
69 {
71 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
72  const mrpt::img::TCamera& cam1 = params.leftCamera;
73  const mrpt::img::TCamera& cam2 = params.rightCamera;
74 
75  ASSERT_(cam1.ncols == cam2.ncols && cam1.nrows == cam2.nrows);
76 
77  const uint32_t ncols = cam1.ncols;
78  const uint32_t nrows = cam1.nrows;
79 
80  const cv::Size trg_size =
82  ? cv::Size(
84  m_resize_output_value.y) // User requested image scaling
85  : cv::Size(); // Default=don't scale
86 
87  const uint32_t ncols_out =
89  const uint32_t nrows_out =
91 
92  // save a copy for future reference
94 
95  // Create OpenCV's wrappers for output maps:
96  m_dat_mapx_left.resize(2 * nrows_out * ncols_out);
97  m_dat_mapy_left.resize(nrows_out * ncols_out);
98 
99  m_dat_mapx_right.resize(2 * nrows_out * ncols_out);
100  m_dat_mapy_right.resize(nrows_out * ncols_out);
101 
102  CvMat mapx_left =
103  cvMat(nrows_out, ncols_out, CV_16SC2, &m_dat_mapx_left[0]);
104  CvMat mapy_left =
105  cvMat(nrows_out, ncols_out, CV_16UC1, &m_dat_mapy_left[0]);
106  CvMat mapx_right =
107  cvMat(nrows_out, ncols_out, CV_16SC2, &m_dat_mapx_right[0]);
108  CvMat mapy_right =
109  cvMat(nrows_out, ncols_out, CV_16UC1, &m_dat_mapy_right[0]);
110 
111  cv::Mat _mapx_left = cv::cvarrToMat(&mapx_left, false);
112  cv::Mat _mapy_left = cv::cvarrToMat(&mapy_left, false);
113  cv::Mat _mapx_right = cv::cvarrToMat(&mapx_right, false);
114  cv::Mat _mapy_right = cv::cvarrToMat(&mapy_right, false);
115 
116  // right camera pose: Rotation
117  CMatrixDouble44 hMatrix;
118  // NOTE!: OpenCV seems to expect the INVERSE of the pose we keep, so invert
119  // it:
120  mrpt::poses::CPose3D(params.rightCameraPose)
121  .getInverseHomogeneousMatrix(hMatrix);
122 
123  double m1[3][3];
124  for (unsigned int i = 0; i < 3; ++i)
125  for (unsigned int j = 0; j < 3; ++j) m1[i][j] = hMatrix(i, j);
126 
127  // right camera pose: translation
128  double rcTrans[3] = {hMatrix(0, 3), hMatrix(1, 3), hMatrix(2, 3)};
129 
130  double ipl[3][3], ipr[3][3], dpl[5], dpr[5];
131  for (unsigned int i = 0; i < 3; ++i)
132  for (unsigned int j = 0; j < 3; ++j)
133  {
134  ipl[i][j] = cam1.intrinsicParams(i, j);
135  ipr[i][j] = cam2.intrinsicParams(i, j);
136  }
137 
138  for (unsigned int i = 0; i < 5; ++i)
139  {
140  dpl[i] = cam1.dist[i];
141  dpr[i] = cam2.dist[i];
142  }
143 
144  const cv::Mat R(3, 3, CV_64F, &m1);
145  const cv::Mat T(3, 1, CV_64F, &rcTrans);
146 
147  const cv::Mat K1(3, 3, CV_64F, ipl);
148  const cv::Mat K2(3, 3, CV_64F, ipr);
149  const cv::Mat D1(1, 5, CV_64F, dpl);
150  const cv::Mat D2(1, 5, CV_64F, dpr);
151 
152  double _R1[3][3], _R2[3][3], _P1[3][4], _P2[3][4], _Q[4][4];
153  cv::Mat R1(3, 3, CV_64F, _R1);
154  cv::Mat R2(3, 3, CV_64F, _R2);
155  cv::Mat P1(3, 4, CV_64F, _P1);
156  cv::Mat P2(3, 4, CV_64F, _P2);
157  cv::Mat Q(4, 4, CV_64F, _Q);
158 
159  const cv::Size img_size(ncols, nrows);
160  const cv::Size real_trg_size =
161  m_resize_output ? trg_size
162  : img_size; // Note: trg_size is Size() by default
163 
164 /*
165 OpenCV 2.0:
166 CV_EXPORTS void stereoRectify( const Mat& cameraMatrix1, const Mat& distCoeffs1,
167  const Mat& cameraMatrix2, const Mat& distCoeffs2,
168  Size imageSize, const Mat& R, const Mat& T,
169  Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q,
170  int flags=CALIB_ZERO_DISPARITY );
171 
172 OpenCV 2.1-2.2:
173 CV_EXPORTS_W void stereoRectify( const Mat& cameraMatrix1, const Mat&
174 distCoeffs1,
175  const Mat& cameraMatrix2, const Mat&
176 distCoeffs2,
177  Size imageSize, const Mat& R, const Mat& T,
178  CV_OUT Mat& R1, CV_OUT Mat& R2,
179  CV_OUT Mat& P1, CV_OUT Mat& P2, CV_OUT Mat& Q,
180  double alpha, Size newImageSize=Size(),
181  CV_OUT Rect* validPixROI1=0, CV_OUT Rect*
182 validPixROI2=0,
183  int flags=CALIB_ZERO_DISPARITY );
184 
185 OpenCV 2.3:
186 CV_EXPORTS void stereoRectify( InputArray cameraMatrix1, InputArray distCoeffs1,
187  InputArray cameraMatrix2, InputArray distCoeffs2,
188  Size imageSize, InputArray R, InputArray T,
189  OutputArray R1, OutputArray R2,
190  OutputArray P1, OutputArray P2,
191  OutputArray Q, int flags=CALIB_ZERO_DISPARITY,
192  double alpha=-1, Size newImageSize=Size(),
193  CV_OUT Rect* validPixROI1=0, CV_OUT Rect*
194 validPixROI2=0 );
195 */
196 #if MRPT_OPENCV_VERSION_NUM < 0x210
197  // OpenCV 2.0.X
198  cv::stereoRectify(
199  K1, D1, K2, D2, img_size, R, T, R1, R2, P1, P2, Q,
200  m_enable_both_centers_coincide ? cv::CALIB_ZERO_DISPARITY : 0);
201 #elif MRPT_OPENCV_VERSION_NUM < 0x230
202  // OpenCV 2.1.X - 2.2.X
203  cv::stereoRectify(
204  K1, D1, K2, D2, img_size, R, T, R1, R2, P1, P2, Q, m_alpha,
205  trg_size, // Size() by default=no resize
206  nullptr, nullptr, // Out ROIs
207  m_enable_both_centers_coincide ? cv::CALIB_ZERO_DISPARITY : 0);
208 #else
209  // OpenCV 2.3+ has this signature:
210  cv::stereoRectify(
211  K1, D1, K2, D2, img_size, R, T, R1, R2, P1, P2, Q,
212  m_enable_both_centers_coincide ? cv::CALIB_ZERO_DISPARITY : 0, m_alpha,
213  trg_size // Size() by default=no resize
214  );
215 // Rest of arguments -> default
216 #endif
217 
218  cv::initUndistortRectifyMap(
219  K1, D1, R1, P1, real_trg_size, CV_16SC2, _mapx_left, _mapy_left);
220  cv::initUndistortRectifyMap(
221  K2, D2, R2, P2, real_trg_size, CV_16SC2, _mapx_right, _mapy_right);
222 
223  // Populate the parameter matrices of the output rectified images:
224  for (unsigned int i = 0; i < 3; ++i)
225  for (unsigned int j = 0; j < 3; ++j)
226  {
228  _P1[i][j];
230  _P2[i][j];
231  }
232  // They have no distortion:
235 
236  // Target image size:
237  m_rectified_image_params.leftCamera.ncols = real_trg_size.width;
238  m_rectified_image_params.leftCamera.nrows = real_trg_size.height;
239 
240  m_rectified_image_params.rightCamera.ncols = real_trg_size.width;
241  m_rectified_image_params.rightCamera.nrows = real_trg_size.height;
242 
243  // Rest of params don't change:
245  params.leftCamera.focalLengthMeters;
247  params.rightCamera.focalLengthMeters;
248 
249  // R1: Rotation of left camera after rectification:
250  // R2: idem for right cam:
251  const Eigen::Map<Eigen::Matrix3d> R1e(R1.ptr<double>());
252  const Eigen::Map<Eigen::Matrix3d> R2e(R2.ptr<double>());
253 
254  CPose3D RR1, RR2;
255  RR1.setRotationMatrix(R1e);
256  RR2.setRotationMatrix(R2e);
257  m_rot_left = CPose3DQuat(RR1);
258  m_rot_right = CPose3DQuat(RR2);
259 
261 
262 #else
263  THROW_EXCEPTION("MRPT built without OpenCV >=2.0.0!");
264 #endif
265  MRPT_END
266 }
267 
269  const mrpt::img::CImage& in_left_image,
270  const mrpt::img::CImage& in_right_image, mrpt::img::CImage& out_left_image,
271  mrpt::img::CImage& out_right_image) const
272 {
273  MRPT_START
274 
275 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
278 
279  const CvSize trg_size =
282  : cvSize(ncols, nrows);
283 
284  out_left_image.resize(
285  trg_size.width, trg_size.height, in_left_image.isColor() ? 3 : 1,
286  in_left_image.isOriginTopLeft());
287  out_right_image.resize(
288  trg_size.width, trg_size.height, in_left_image.isColor() ? 3 : 1,
289  in_left_image.isOriginTopLeft());
290 
291  const IplImage* in_left = in_left_image.getAs<IplImage>();
292  const IplImage* in_right = in_right_image.getAs<IplImage>();
293 
294  IplImage* out_left = out_left_image.getAs<IplImage>();
295  IplImage* out_right = out_right_image.getAs<IplImage>();
296 
297  this->rectify_IPL(in_left, in_right, out_left, out_right);
298 
299 #endif
300  MRPT_END
301 }
302 
303 // In place:
305  mrpt::img::CImage& left_image, mrpt::img::CImage& right_image,
306  const bool use_internal_mem_cache) const
307 {
308  MRPT_START
309 
310 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
313 
314  const CvSize trg_size =
317  : cvSize(ncols, nrows);
318 
319  const IplImage* in_left = left_image.getAs<IplImage>();
320  const IplImage* in_right = right_image.getAs<IplImage>();
321 
322  IplImage *out_left_image, *out_right_image;
323  if (use_internal_mem_cache)
324  {
326  trg_size.width, trg_size.height, left_image.isColor() ? 3 : 1,
327  left_image.isOriginTopLeft());
329  trg_size.width, trg_size.height, right_image.isColor() ? 3 : 1,
330  right_image.isOriginTopLeft());
331 
332  out_left_image = m_cache1.getAs<IplImage>();
333  out_right_image = m_cache2.getAs<IplImage>();
334  }
335  else
336  {
337  out_left_image =
338  cvCreateImage(trg_size, in_left->depth, in_left->nChannels);
339  out_right_image =
340  cvCreateImage(trg_size, in_right->depth, in_right->nChannels);
341  }
342 
343  this->rectify_IPL(in_left, in_right, out_left_image, out_right_image);
344 
345  if (use_internal_mem_cache)
346  {
347  // Copy the data: we have avoided one allocation & one deallocation
348  // (If the sizes match, these calls have no effects)
349  left_image.resize(
350  trg_size.width, trg_size.height, left_image.isColor() ? 3 : 1,
351  left_image.isOriginTopLeft());
352  right_image.resize(
353  trg_size.width, trg_size.height, right_image.isColor() ? 3 : 1,
354  right_image.isOriginTopLeft());
355 
356  cvCopy(out_left_image, left_image.getAs<IplImage>());
357  cvCopy(out_right_image, right_image.getAs<IplImage>());
358  }
359  else
360  {
361  // Move the internal pointers: but we deallocate the old contents and
362  // needed to allocate this one
363  left_image.setFromIplImage(out_left_image);
364  right_image.setFromIplImage(out_right_image);
365  }
366 
367 #endif
368  MRPT_END
369 }
370 
371 /** Overloaded version for in-place rectification of image pairs stored in a
372  * mrpt::obs::CObservationStereoImages.
373  * Upon return, the new camera intrinsic parameters will be already stored in
374  * the observation object.
375  */
377  mrpt::obs::CObservationStereoImages& stereo_image_observation,
378  const bool use_internal_mem_cache) const
379 {
380  MRPT_START
381  ASSERT_(stereo_image_observation.hasImageRight);
382 
383  // Rectify images:
384  this->rectify(
385  stereo_image_observation.imageLeft, stereo_image_observation.imageRight,
386  use_internal_mem_cache);
387 
388  // Copy output image parameters:
389  stereo_image_observation.setStereoCameraParams(
391 
392  // Correct poses:
393  stereo_image_observation.cameraPose += m_rot_left;
394 
395  const double d = stereo_image_observation.rightCameraPose.m_coords.norm();
396  // the translation is now pure in the +X direction:
397  stereo_image_observation.rightCameraPose =
399 
400  MRPT_END
401 }
402 
403 /** Just like rectify() but directly works with OpenCV's "IplImage*", which must
404  * be passed as "void*" to avoid header dependencies */
406  const void* srcImg_left, const void* srcImg_right, void* outImg_left,
407  void* outImg_right) const
408 {
409  MRPT_START
410  ASSERT_(srcImg_left != outImg_left && srcImg_right != outImg_right);
411 
412  if (!isSet())
414  "Error: setFromCamParams() must be called prior to rectify().")
415 
416 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
419 
420  const uint32_t ncols_out =
422  const uint32_t nrows_out =
424 
425  const CvMat mapx_left = cvMat(
426  nrows_out, ncols_out, CV_16SC2,
427  const_cast<int16_t*>(&m_dat_mapx_left[0]));
428  const CvMat mapy_left = cvMat(
429  nrows_out, ncols_out, CV_16UC1,
430  const_cast<uint16_t*>(&m_dat_mapy_left[0]));
431  const CvMat mapx_right = cvMat(
432  nrows_out, ncols_out, CV_16SC2,
433  const_cast<int16_t*>(&m_dat_mapx_right[0]));
434  const CvMat mapy_right = cvMat(
435  nrows_out, ncols_out, CV_16UC1,
436  const_cast<uint16_t*>(&m_dat_mapy_right[0]));
437 
438  const cv::Mat mapx1 = cv::cvarrToMat(&mapx_left);
439  const cv::Mat mapy1 = cv::cvarrToMat(&mapy_left);
440  const cv::Mat mapx2 = cv::cvarrToMat(&mapx_right);
441  const cv::Mat mapy2 = cv::cvarrToMat(&mapy_right);
442 
443  const cv::Mat src1 = cv::cvarrToMat(srcImg_left);
444  const cv::Mat src2 = cv::cvarrToMat(srcImg_right);
445  cv::Mat dst1 = cv::cvarrToMat(outImg_left);
446  cv::Mat dst2 = cv::cvarrToMat(outImg_right);
447 
448  cv::remap(
449  src1, dst1, mapx1, mapy1, static_cast<int>(m_interpolation_method),
450  cv::BORDER_CONSTANT, cvScalarAll(0));
451  cv::remap(
452  src2, dst2, mapx2, mapy2, static_cast<int>(m_interpolation_method),
453  cv::BORDER_CONSTANT, cvScalarAll(0));
454 #endif
455  MRPT_END
456 }
457 
459  const
460 {
461  if (!isSet())
462  THROW_EXCEPTION("Error: setFromCamParams() must be called before.");
464 }
465 
467 {
468  if (!isSet())
469  THROW_EXCEPTION("Error: setFromCamParams() must be called before.");
471 }
472 
474  const
475 {
476  if (!isSet())
477  THROW_EXCEPTION("Error: setFromCamParams() must be called before.");
479 }
480 
482  const std::vector<int16_t>& left_x, const std::vector<uint16_t>& left_y,
483  const std::vector<int16_t>& right_x, const std::vector<uint16_t>& right_y)
484 {
485  m_dat_mapx_left.resize(left_x.size());
486  m_dat_mapy_left.resize(left_y.size());
487  m_dat_mapx_right.resize(right_x.size());
488  m_dat_mapy_right.resize(right_y.size());
489 
490  std::copy(left_x.begin(), left_x.end(), m_dat_mapx_left.begin());
491  std::copy(left_y.begin(), left_y.end(), m_dat_mapy_left.begin());
492  std::copy(right_x.begin(), right_x.end(), m_dat_mapx_right.begin());
493  std::copy(right_y.begin(), right_y.end(), m_dat_mapy_right.begin());
494 }
495 
497  std::vector<int16_t>& left_x, std::vector<uint16_t>& left_y,
498  std::vector<int16_t>& right_x, std::vector<uint16_t>& right_y)
499 {
500  left_x.swap(m_dat_mapx_left);
501  left_y.swap(m_dat_mapy_left);
502  right_x.swap(m_dat_mapx_right);
503  right_y.swap(m_dat_mapy_right);
504 }
mrpt::obs::CObservationStereoImages::setStereoCameraParams
void setStereoCameraParams(const mrpt::img::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
Definition: CObservationStereoImages.cpp:204
mrpt::img::CImage::resize
void resize(unsigned int width, unsigned int height, TImageChannels nChannels, bool originTopLeft)
Changes the size of the image, erasing previous contents (does NOT scale its current content,...
Definition: img/CImage.h:261
mrpt::img::TCamera::intrinsicParams
mrpt::math::CMatrixDouble33 intrinsicParams
Matrix of intrinsic parameters (containing the focal length and principal point coordinates)
Definition: TCamera.h:44
uint16_t
unsigned __int16 uint16_t
Definition: rptypes.h:44
mrpt::vision::CStereoRectifyMap::m_rot_left
mrpt::poses::CPose3DQuat m_rot_left
The rotation applied to the left/right camera so their virtual image plane is the same after rectific...
Definition: CStereoRectifyMap.h:302
mrpt::vision::CStereoRectifyMap::m_alpha
double m_alpha
Definition: CStereoRectifyMap.h:283
mrpt::vision::CStereoRectifyMap::setAlpha
void setAlpha(double alpha)
Sets the alpha parameter which controls the zoom in/out of the rectified images, such that:
Definition: CStereoRectifyMap.cpp:41
mrpt::vision::CStereoRectifyMap::getRectifiedLeftImageParams
const mrpt::img::TCamera & getRectifiedLeftImageParams() const
Just like getRectifiedImageParams() but for the left camera only.
Definition: CStereoRectifyMap.cpp:466
mrpt::vision
Classes for computer vision, detectors, features, etc.
Definition: CCamModel.h:20
mrpt::img::TCamera::ncols
uint32_t ncols
Camera resolution.
Definition: TCamera.h:41
mrpt::vision::CStereoRectifyMap::getRectifiedRightImageParams
const mrpt::img::TCamera & getRectifiedRightImageParams() const
Just like getRectifiedImageParams() but for the right camera only.
Definition: CStereoRectifyMap.cpp:473
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::img::CImage::getAs
const T * getAs() const
Returns a pointer to a const T* containing the image - the idea is to call like "img....
Definition: img/CImage.h:599
R
const float R
Definition: CKinematicChain.cpp:138
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
mrpt::poses::CPose3DQuat
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
Definition: CPose3DQuat.h:48
ASSERT_
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
mrpt::vision::CStereoRectifyMap::m_cache1
mrpt::img::CImage m_cache1
Memory caches for in-place rectification speed-up.
Definition: CStereoRectifyMap.h:290
alpha
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3525
mrpt::vision::CStereoRectifyMap::getRectifiedImageParams
const mrpt::img::TStereoCamera & getRectifiedImageParams() const
After computing the rectification maps, this method retrieves the calibration parameters of the recti...
Definition: CStereoRectifyMap.cpp:458
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
mrpt::obs::CObservationStereoImages::imageRight
mrpt::img::CImage imageRight
Image from the right camera, only contains a valid image if hasImageRight == true.
Definition: CObservationStereoImages.h:72
vision-precomp.h
mrpt::img::CImage::isColor
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
Definition: CImage.cpp:906
mrpt::img::TCamera::focalLengthMeters
double focalLengthMeters
The focal length of the camera, in meters (can be used among 'intrinsicParams' to determine the pixel...
Definition: TCamera.h:50
mrpt::vision::CStereoRectifyMap::m_rot_right
mrpt::poses::CPose3DQuat m_rot_right
Definition: CStereoRectifyMap.h:302
mrpt::img::TStereoCamera::rightCamera
TCamera rightCamera
Definition: TStereoCamera.h:30
mrpt::img::IMG_INTERP_LINEAR
@ IMG_INTERP_LINEAR
Definition: img/CImage.h:37
CStereoRectifyMap.h
mrpt::img
Definition: CCanvas.h:17
int16_t
__int16 int16_t
Definition: rptypes.h:43
mrpt::obs::CObservationStereoImages::imageLeft
mrpt::img::CImage imageLeft
Image from the left camera (this image will be ALWAYS present)
Definition: CObservationStereoImages.h:68
mrpt::vision::CStereoRectifyMap::setRectifyMapsFast
void setRectifyMapsFast(std::vector< int16_t > &left_x, std::vector< uint16_t > &left_y, std::vector< int16_t > &right_x, std::vector< uint16_t > &right_y)
Direct input access to rectify maps.
Definition: CStereoRectifyMap.cpp:496
mrpt::vision::CStereoRectifyMap::m_interpolation_method
mrpt::img::TInterpolationMethod m_interpolation_method
Definition: CStereoRectifyMap.h:287
MRPT_START
#define MRPT_START
Definition: exceptions.h:262
mrpt::img::TStereoCamera
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:25
mrpt::img::TCamera::nrows
uint32_t nrows
Definition: TCamera.h:41
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::img::CImage::isOriginTopLeft
bool isOriginTopLeft() const
Returns true if the coordinates origin is top-left, or false if it is bottom-left
Definition: CImage.cpp:934
mrpt::img::TStereoCamera::rightCameraPose
mrpt::math::TPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
Definition: TStereoCamera.h:33
mrpt::vision::CStereoRectifyMap::m_dat_mapy_left
std::vector< uint16_t > m_dat_mapy_left
Definition: CStereoRectifyMap.h:293
mrpt::vision::CStereoRectifyMap::m_camera_params
mrpt::img::TStereoCamera m_camera_params
A copy of the data provided by the user.
Definition: CStereoRectifyMap.h:296
mrpt::img::TCamera
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:29
mrpt::poses::CPoseOrPoint::getInverseHomogeneousMatrix
void getInverseHomogeneousMatrix(MATRIX44 &out_HM) const
Returns the corresponding 4x4 inverse homogeneous transformation matrix for this point or pose.
Definition: CPoseOrPoint.h:287
mrpt::vision::CStereoRectifyMap::enableResizeOutput
void enableResizeOutput(bool enable, unsigned int target_width=0, unsigned int target_height=0)
If enabled, the computed maps will rectify images to a size different than their original size.
Definition: CStereoRectifyMap.cpp:48
mrpt::vision::CStereoRectifyMap::m_rectified_image_params
mrpt::img::TStereoCamera m_rectified_image_params
Resulting images params.
Definition: CStereoRectifyMap.h:298
mrpt::vision::CStereoRectifyMap::m_enable_both_centers_coincide
bool m_enable_both_centers_coincide
Definition: CStereoRectifyMap.h:285
mrpt::vision::CStereoRectifyMap::m_resize_output
bool m_resize_output
Definition: CStereoRectifyMap.h:284
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:40
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
mrpt::vision::CStereoRectifyMap::setRectifyMaps
void setRectifyMaps(const std::vector< int16_t > &left_x, const std::vector< uint16_t > &left_y, const std::vector< int16_t > &right_x, const std::vector< uint16_t > &right_y)
Direct input access to rectify maps.
Definition: CStereoRectifyMap.cpp:481
mrpt::vision::CStereoRectifyMap::setFromCamParams
void setFromCamParams(const mrpt::img::TStereoCamera &params)
Prepares the mapping from the intrinsic, distortion and relative pose parameters of a stereo camera.
Definition: CStereoRectifyMap.cpp:68
mrpt::math::CQuaternion
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ,...
Definition: CQuaternion.h:46
mrpt::img::TCamera::dist
std::array< double, 5 > dist
[k1 k2 t1 t2 k3] -> k_i: parameters of radial distortion, t_i: parameters of tangential distortion (d...
Definition: TCamera.h:47
mrpt::img::CImage::setFromIplImage
void setFromIplImage(void *iplImage)
Reads the image from a OpenCV IplImage object (WITHOUT making a copy).
Definition: CImage.cpp:363
img
GLint GLvoid * img
Definition: glext.h:3763
mrpt::vision::CStereoRectifyMap::rectify
void rectify(const mrpt::img::CImage &in_left_image, const mrpt::img::CImage &in_right_image, mrpt::img::CImage &out_left_image, mrpt::img::CImage &out_right_image) const
Rectify the input image pair and save the result in a different output images - setFromCamParams() mu...
Definition: CStereoRectifyMap.cpp:268
mrpt::vision::CStereoRectifyMap::internal_invalidate
void internal_invalidate()
Definition: CStereoRectifyMap.cpp:32
mrpt::obs::CObservationStereoImages::cameraPose
mrpt::poses::CPose3DQuat cameraPose
The pose of the LEFT camera, relative to the robot.
Definition: CObservationStereoImages.h:96
MRPT_END
#define MRPT_END
Definition: exceptions.h:266
mrpt::vision::CStereoRectifyMap::m_dat_mapx_left
std::vector< int16_t > m_dat_mapx_left
Definition: CStereoRectifyMap.h:292
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
mrpt::vision::CStereoRectifyMap::isSet
bool isSet() const
Returns true if setFromCamParams() has been already called, false otherwise.
Definition: CStereoRectifyMap.h:90
mrpt::vision::CStereoRectifyMap::m_dat_mapy_right
std::vector< uint16_t > m_dat_mapy_right
Definition: CStereoRectifyMap.h:293
mrpt::vision::CStereoRectifyMap::enableBothCentersCoincide
void enableBothCentersCoincide(bool enable=true)
If enabled (default=false), the principal points in both output images will coincide.
Definition: CStereoRectifyMap.cpp:58
mrpt::vision::CStereoRectifyMap::m_dat_mapx_right
std::vector< int16_t > m_dat_mapx_right
Definition: CStereoRectifyMap.h:292
mrpt::img::TStereoCamera::leftCamera
TCamera leftCamera
Intrinsic and distortion parameters of the left and right cameras.
Definition: TStereoCamera.h:30
mrpt::obs::CObservationStereoImages::hasImageRight
bool hasImageRight
Whether imageRight actually contains data (Default upon construction: true)
Definition: CObservationStereoImages.h:85
mrpt::poses::CPose3D::setRotationMatrix
void setRotationMatrix(const mrpt::math::CMatrixDouble33 &ROT)
Sets the 3x3 rotation matrix.
Definition: CPose3D.h:244
mrpt::poses::CPose3DQuat::m_coords
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z].
Definition: CPose3DQuat.h:55
mrpt::obs::CObservationStereoImages::rightCameraPose
mrpt::poses::CPose3DQuat rightCameraPose
The pose of the right camera, relative to the left one: Note that using the conventional reference co...
Definition: CObservationStereoImages.h:104
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
mrpt::obs::CObservationStereoImages
Observation class for either a pair of left+right or left+disparity images from a stereo camera.
Definition: CObservationStereoImages.h:41
mrpt::vision::CStereoRectifyMap::rectify_IPL
void rectify_IPL(const void *in_left_image, const void *in_right_image, void *out_left_image, void *out_right_image) const
Just like rectify() but directly works with OpenCV's "IplImage*", which must be passed as "void*" to ...
Definition: CStereoRectifyMap.cpp:405
params
GLenum const GLfloat * params
Definition: glext.h:3534
mrpt::vision::CStereoRectifyMap::m_resize_output_value
mrpt::img::TImageSize m_resize_output_value
Definition: CStereoRectifyMap.h:286
mrpt::vision::CStereoRectifyMap::m_cache2
mrpt::img::CImage m_cache2
Definition: CStereoRectifyMap.h:290



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