MRPT  1.9.9
CObservation3DRangeScan_project3D_impl.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/core/round.h> // round()
12 #include <mrpt/math/CVectorFixed.h>
13 #include <Eigen/Dense> // block<>()
14 
15 namespace mrpt::obs::detail
16 {
17 // Auxiliary functions which implement SSE-optimized proyection of 3D point
18 // cloud:
19 template <class POINTMAP>
21  const int H, const int W, const float* kys, const float* kzs,
22  mrpt::math::CMatrixF& rangeImage,
24  std::vector<uint16_t>& idxs_x, std::vector<uint16_t>& idxs_y,
25  const mrpt::obs::TRangeImageFilterParams& fp, bool MAKE_ORGANIZED,
26  const int DECIM);
27 template <class POINTMAP>
29  const int H, const int W, const float* kys, const float* kzs,
30  mrpt::math::CMatrixF& rangeImage,
32  std::vector<uint16_t>& idxs_x, std::vector<uint16_t>& idxs_y,
33  const mrpt::obs::TRangeImageFilterParams& fp, bool MAKE_ORGANIZED);
34 
35 template <typename POINTMAP, bool isDepth>
36 inline void range2XYZ(
39  const mrpt::obs::TRangeImageFilterParams& fp, const int H, const int W)
40 {
41  /* range_is_depth = false :
42  * Ky = (r_cx - c)/r_fx
43  * Kz = (r_cy - r)/r_fy
44  *
45  * x(i) = rangeImage(r,c) / sqrt( 1 + Ky^2 + Kz^2 )
46  * y(i) = Ky * x(i)
47  * z(i) = Kz * x(i)
48  */
49  const float r_cx = src_obs.cameraParams.cx();
50  const float r_cy = src_obs.cameraParams.cy();
51  const float r_fx_inv = 1.0f / src_obs.cameraParams.fx();
52  const float r_fy_inv = 1.0f / src_obs.cameraParams.fy();
53  TRangeImageFilter rif(fp);
54  size_t idx = 0;
55  for (int r = 0; r < H; r++)
56  for (int c = 0; c < W; c++)
57  {
58  const float D = src_obs.rangeImage.coeff(r, c);
59  if (rif.do_range_filter(r, c, D))
60  {
61  const float Ky = (r_cx - c) * r_fx_inv;
62  const float Kz = (r_cy - r) * r_fy_inv;
63  pca.setPointXYZ(
64  idx,
65  isDepth ? D : D / std::sqrt(1 + Ky * Ky + Kz * Kz), // x
66  Ky * D, // y
67  Kz * D // z
68  );
69  src_obs.points3D_idxs_x[idx] = c;
70  src_obs.points3D_idxs_y[idx] = r;
71  ++idx;
72  }
73  else
74  {
75  if (fp.mark_invalid_ranges)
76  src_obs.rangeImage.coeffRef(r, c) = 0;
77  }
78  }
79  pca.resize(idx); // Actual number of valid pts
80 }
81 
82 template <typename POINTMAP, bool isDepth>
83 inline void range2XYZ_LUT(
87  const mrpt::obs::TRangeImageFilterParams& fp, const int H, const int W,
88  const int DECIM = 1)
89 {
90  const size_t WH = W * H;
91  if (src_obs.get_3dproj_lut().prev_camParams != src_obs.cameraParams ||
92  WH != size_t(src_obs.get_3dproj_lut().Kys.size()))
93  {
94  src_obs.get_3dproj_lut().prev_camParams = src_obs.cameraParams;
95  src_obs.get_3dproj_lut().Kys.resize(WH);
96  src_obs.get_3dproj_lut().Kzs.resize(WH);
97 
98  const float r_cx = src_obs.cameraParams.cx();
99  const float r_cy = src_obs.cameraParams.cy();
100  const float r_fx_inv = 1.0f / src_obs.cameraParams.fx();
101  const float r_fy_inv = 1.0f / src_obs.cameraParams.fy();
102 
103  float* kys = &src_obs.get_3dproj_lut().Kys[0];
104  float* kzs = &src_obs.get_3dproj_lut().Kzs[0];
105  for (int r = 0; r < H; r++)
106  for (int c = 0; c < W; c++)
107  {
108  *kys++ = (r_cx - c) * r_fx_inv;
109  *kzs++ = (r_cy - r) * r_fy_inv;
110  }
111  } // end update LUT.
112 
113  ASSERT_EQUAL_(WH, size_t(src_obs.get_3dproj_lut().Kys.size()));
114  ASSERT_EQUAL_(WH, size_t(src_obs.get_3dproj_lut().Kzs.size()));
115  float* kys = &src_obs.get_3dproj_lut().Kys[0];
116  float* kzs = &src_obs.get_3dproj_lut().Kzs[0];
117 
118  if (fp.rangeMask_min)
119  { // sanity check:
120  ASSERT_EQUAL_(fp.rangeMask_min->cols(), src_obs.rangeImage.cols());
121  ASSERT_EQUAL_(fp.rangeMask_min->rows(), src_obs.rangeImage.rows());
122  }
123  if (fp.rangeMask_max)
124  { // sanity check:
125  ASSERT_EQUAL_(fp.rangeMask_max->cols(), src_obs.rangeImage.cols());
126  ASSERT_EQUAL_(fp.rangeMask_max->rows(), src_obs.rangeImage.rows());
127  }
128 #if MRPT_HAS_SSE2
129  // if image width is not 8*N, use standard method
130  if ((W & 0x07) == 0 && pp.USE_SSE2 && DECIM == 1)
132  H, W, kys, kzs, src_obs.rangeImage, pca, src_obs.points3D_idxs_x,
133  src_obs.points3D_idxs_y, fp, pp.MAKE_ORGANIZED);
134  else
135 #endif
137  H, W, kys, kzs, src_obs.rangeImage, pca, src_obs.points3D_idxs_x,
138  src_obs.points3D_idxs_y, fp, pp.MAKE_ORGANIZED, DECIM);
139 }
140 
141 template <class POINTMAP>
143  mrpt::obs::CObservation3DRangeScan& src_obs, POINTMAP& dest_pointcloud,
146 {
147  using namespace mrpt::math;
148 
149  if (!src_obs.hasRangeImage) return;
150 
151  mrpt::opengl::PointCloudAdapter<POINTMAP> pca(dest_pointcloud);
152 
153  // ------------------------------------------------------------
154  // Stage 1/3: Create 3D point cloud local coordinates
155  // ------------------------------------------------------------
156  const int W = src_obs.rangeImage.cols();
157  const int H = src_obs.rangeImage.rows();
158  ASSERT_(W != 0 && H != 0);
159  const size_t WH = W * H;
160 
161  if (pp.decimation == 1)
162  {
163  // No decimation: one point per range image pixel
164 
165  // This is to make sure points3D_idxs_{x,y} have the expected sizes
166  src_obs.resizePoints3DVectors(WH);
167  // Reserve memory for 3D points. It will be later resized again to the
168  // actual number of valid points
169  pca.resize(WH);
170  if (pp.MAKE_ORGANIZED) pca.setDimensions(H, W);
171  if (src_obs.range_is_depth)
172  {
173  // range_is_depth = true
174  // Use cached tables?
175  if (pp.PROJ3D_USE_LUT)
176  range2XYZ_LUT<POINTMAP, true>(pca, src_obs, pp, fp, H, W);
177  else
178  range2XYZ<POINTMAP, true>(pca, src_obs, fp, H, W);
179  }
180  else
181  range2XYZ<POINTMAP, false>(pca, src_obs, fp, H, W);
182  }
183  else
184  {
185  // Decimate range image:
186  const auto DECIM = pp.decimation;
187  ASSERTMSG_(
188  (W % DECIM) == 0 && (H % DECIM == 0),
189  "Width/Height are not an exact multiple of decimation");
190  const int Wd = W / DECIM;
191  const int Hd = H / DECIM;
192  ASSERT_(Wd != 0 && Hd != 0);
193  const size_t WHd = Wd * Hd;
194 
195  src_obs.resizePoints3DVectors(WHd);
196  pca.resize(WHd);
197  if (pp.MAKE_ORGANIZED) pca.setDimensions(Hd, Wd);
198  ASSERTMSG_(
199  src_obs.range_is_depth && pp.PROJ3D_USE_LUT,
200  "Decimation only available if range_is_depth && PROJ3D_USE_LUT");
201  range2XYZ_LUT<POINTMAP, true>(pca, src_obs, pp, fp, H, W, DECIM);
202  }
203 
204  // -------------------------------------------------------------
205  // Stage 2/3: Project local points into RGB image to get colors
206  // -------------------------------------------------------------
207  if constexpr (pca.HAS_RGB)
208  {
209  if (src_obs.hasIntensityImage)
210  {
211  const int imgW = src_obs.intensityImage.getWidth();
212  const int imgH = src_obs.intensityImage.getHeight();
213  const bool hasColorIntensityImg = src_obs.intensityImage.isColor();
214 
215  const float cx = src_obs.cameraParamsIntensity.cx();
216  const float cy = src_obs.cameraParamsIntensity.cy();
217  const float fx = src_obs.cameraParamsIntensity.fx();
218  const float fy = src_obs.cameraParamsIntensity.fy();
219 
220  // Unless we are in a special case (both depth & RGB images
221  // coincide)...
222  const bool isDirectCorresp =
224 
225  // ...precompute the inverse of the pose transformation out of
226  // the
227  // loop,
228  // store as a 4x4 homogeneous matrix to exploit SSE
229  // optimizations
230  // below:
232  if (!isDirectCorresp)
233  {
239  t_inv);
240 
241  T_inv(3, 3) = 1;
242  T_inv.insertMatrix(0, 0, R_inv.cast_float());
243  T_inv.insertMatrix(0, 3, t_inv.cast_float());
244  }
245 
246  CVectorFixedFloat<4> pt_wrt_color, pt_wrt_depth;
247  pt_wrt_depth[3] = 1;
248  mrpt::img::TColor pCol;
249 
250  // For each local point:
251  const size_t nPts = pca.size();
252  const auto& iimg = src_obs.intensityImage;
253  const uint8_t* img_data = iimg.ptrLine<uint8_t>(0);
254  const auto img_stride = iimg.getRowStride();
255  for (size_t i = 0; i < nPts; i++)
256  {
257  int img_idx_x,
258  img_idx_y; // projected pixel coordinates, in the
259  // RGB image plane
260  bool pointWithinImage = false;
261  if (isDirectCorresp)
262  {
263  pointWithinImage = true;
264  img_idx_x = src_obs.points3D_idxs_x[i];
265  img_idx_y = src_obs.points3D_idxs_y[i];
266  }
267  else
268  {
269  // Project point, which is now in "pca" in local
270  // coordinates
271  // wrt the depth camera, into the intensity camera:
272  pca.getPointXYZ(
273  i, pt_wrt_depth[0], pt_wrt_depth[1], pt_wrt_depth[2]);
274  pt_wrt_color = T_inv * pt_wrt_depth;
275 
276  // Project to image plane:
277  if (pt_wrt_color[2])
278  {
279  img_idx_x = mrpt::round(
280  cx + fx * pt_wrt_color[0] / pt_wrt_color[2]);
281  img_idx_y = mrpt::round(
282  cy + fy * pt_wrt_color[1] / pt_wrt_color[2]);
283  pointWithinImage = img_idx_x >= 0 && img_idx_x < imgW &&
284  img_idx_y >= 0 && img_idx_y < imgH;
285  }
286  }
287 
288  if (pointWithinImage)
289  {
290  if (hasColorIntensityImg)
291  {
292  const auto px_idx =
293  img_stride * img_idx_y + 3 * img_idx_x;
294  pCol.R = img_data[px_idx + 2];
295  pCol.G = img_data[px_idx + 1];
296  pCol.B = img_data[px_idx + 0];
297  }
298  else
299  {
300  const auto px_idx = img_stride * img_idx_y + img_idx_x;
301  pCol.R = pCol.G = pCol.B = img_data[px_idx];
302  }
303  }
304  else
305  {
306  pCol.R = pCol.G = pCol.B = 255;
307  }
308  // Set color:
309  pca.setPointRGBu8(i, pCol.R, pCol.G, pCol.B);
310  } // end for each point
311  } // end if src_obs has intensity image
312  }
313  // ...
314 
315  // ------------------------------------------------------------
316  // Stage 3/3: Apply 6D transformations
317  // ------------------------------------------------------------
319  {
320  mrpt::poses::CPose3D transf_to_apply; // Either ROBOTPOSE or
321  // ROBOTPOSE(+)SENSORPOSE or
322  // SENSORPOSE
324  transf_to_apply = src_obs.sensorPose;
325  if (pp.robotPoseInTheWorld)
326  transf_to_apply.composeFrom(
327  *pp.robotPoseInTheWorld, mrpt::poses::CPose3D(transf_to_apply));
328 
329  const auto HM =
330  transf_to_apply
332  .cast_float();
333  mrpt::math::CVectorFixedFloat<4> pt, pt_transf;
334  pt[3] = 1;
335 
336  const size_t nPts = pca.size();
337  for (size_t i = 0; i < nPts; i++)
338  {
339  pca.getPointXYZ(i, pt[0], pt[1], pt[2]);
340  pt_transf = HM * pt;
341  pca.setPointXYZ(i, pt_transf[0], pt_transf[1], pt_transf[2]);
342  }
343  }
344 } // end of project3DPointsFromDepthImageInto
345 
346 // Auxiliary functions which implement (un)projection of 3D point clouds:
347 template <class POINTMAP>
349  const int H, const int W, const float* kys, const float* kzs,
350  mrpt::math::CMatrixF& rangeImage,
352  std::vector<uint16_t>& idxs_x, std::vector<uint16_t>& idxs_y,
353  const mrpt::obs::TRangeImageFilterParams& fp, bool MAKE_ORGANIZED,
354  const int DECIM)
355 {
356  TRangeImageFilter rif(fp);
357  // Preconditions: minRangeMask() has the right size
358  size_t idx = 0;
359  if (DECIM == 1)
360  {
361  for (int r = 0; r < H; r++)
362  for (int c = 0; c < W; c++)
363  {
364  const float D = rangeImage.coeff(r, c);
365  // LUT projection coefs:
366  const auto ky = *kys++, kz = *kzs++;
367  if (!rif.do_range_filter(r, c, D))
368  {
369  if (MAKE_ORGANIZED) pca.setInvalidPoint(idx++);
370  if (fp.mark_invalid_ranges) rangeImage.coeffRef(r, c) = 0;
371  continue;
372  }
373  pca.setPointXYZ(idx, D /*x*/, ky * D /*y*/, kz * D /*z*/);
374  idxs_x[idx] = c;
375  idxs_y[idx] = r;
376  ++idx;
377  }
378  }
379  else
380  {
381  const int Hd = H / DECIM, Wd = W / DECIM;
382 
383  for (int rd = 0; rd < Hd; rd++)
384  for (int cd = 0; cd < Wd; cd++)
385  {
386  bool valid_pt = false;
387  float min_d = std::numeric_limits<float>::max();
388  for (int rb = 0; rb < DECIM; rb++)
389  for (int cb = 0; cb < DECIM; cb++)
390  {
391  const auto r = rd * DECIM + rb, c = cd * DECIM + cb;
392  const float D = rangeImage.coeff(r, c);
393  if (rif.do_range_filter(r, c, D))
394  {
395  valid_pt = true;
396  if (D < min_d) min_d = D;
397  }
398  else
399  {
400  if (fp.mark_invalid_ranges)
401  rangeImage.coeffRef(r, c) = 0;
402  }
403  }
404  if (!valid_pt)
405  {
406  if (MAKE_ORGANIZED) pca.setInvalidPoint(idx++);
407  continue;
408  }
409  const auto eq_r = rd * DECIM + DECIM / 2,
410  eq_c = cd * DECIM + DECIM / 2;
411  const auto ky = kys[eq_c + eq_r * W], kz = kzs[eq_c + eq_r * W];
412  pca.setPointXYZ(
413  idx, min_d /*x*/, ky * min_d /*y*/, kz * min_d /*z*/);
414  idxs_x[idx] = eq_c;
415  idxs_y[idx] = eq_r;
416  ++idx;
417  }
418  }
419  pca.resize(idx);
420  // Make sure indices are also resized down to the actual number of points,
421  // even if they are not part of the object PCA refers to:
422  idxs_x.resize(idx);
423  idxs_y.resize(idx);
424 }
425 
426 // Auxiliary functions which implement (un)projection of 3D point clouds:
427 template <class POINTMAP>
429  const int H, const int W, const float* kys, const float* kzs,
430  mrpt::math::CMatrixF& rangeImage,
432  std::vector<uint16_t>& idxs_x, std::vector<uint16_t>& idxs_y,
433  const mrpt::obs::TRangeImageFilterParams& fp, bool MAKE_ORGANIZED)
434 {
435 #if MRPT_HAS_SSE2
436  // Preconditions: minRangeMask() has the right size
437  // Use optimized version:
438  const int W_4 = W >> 2; // /=4 , since we process 4 values at a time.
439  size_t idx = 0;
440  alignas(MRPT_MAX_STATIC_ALIGN_BYTES) float xs[4], ys[4], zs[4];
441  const __m128 D_zeros = _mm_set_ps(.0f, .0f, .0f, .0f);
442  const __m128 xormask =
443  (fp.rangeCheckBetween) ? _mm_cmpneq_ps(D_zeros, D_zeros)
444  : // want points BETWEEN min and max to be valid
445  _mm_cmpeq_ps(
446  D_zeros,
447  D_zeros); // want points OUTSIDE of min and max to be valid
448  for (int r = 0; r < H; r++)
449  {
450  const float* D_ptr = &rangeImage(r, 0); // Matrices are 16-aligned
451  const float* Dgt_ptr =
452  !fp.rangeMask_min ? nullptr : &(*fp.rangeMask_min)(r, 0);
453  const float* Dlt_ptr =
454  !fp.rangeMask_max ? nullptr : &(*fp.rangeMask_max)(r, 0);
455 
456  for (int c = 0; c < W_4; c++)
457  {
458  const __m128 D = _mm_load_ps(D_ptr);
459  const __m128 nz_mask = _mm_cmpgt_ps(D, D_zeros);
460  __m128 valid_range_mask;
461  if (!fp.rangeMask_min && !fp.rangeMask_max)
462  { // No filter: just skip D=0 points
463  valid_range_mask = nz_mask;
464  }
465  else
466  {
467  if (!fp.rangeMask_min || !fp.rangeMask_max)
468  { // Only one filter
469  if (fp.rangeMask_min)
470  {
471  const __m128 Dmin = _mm_load_ps(Dgt_ptr);
472  valid_range_mask = _mm_or_ps(
473  _mm_cmpgt_ps(D, Dmin), _mm_cmpeq_ps(Dmin, D_zeros));
474  }
475  else
476  {
477  const __m128 Dmax = _mm_load_ps(Dlt_ptr);
478  valid_range_mask = _mm_or_ps(
479  _mm_cmplt_ps(D, Dmax), _mm_cmpeq_ps(Dmax, D_zeros));
480  }
481  valid_range_mask = _mm_and_ps(
482  valid_range_mask, nz_mask); // Filter out D=0 points
483  }
484  else
485  {
486  // We have both: D>Dmin and D<Dmax conditions, with XOR to
487  // optionally invert the selection:
488  const __m128 Dmin = _mm_load_ps(Dgt_ptr);
489  const __m128 Dmax = _mm_load_ps(Dlt_ptr);
490 
491  const __m128 gt_mask = _mm_or_ps(
492  _mm_cmpgt_ps(D, Dmin), _mm_cmpeq_ps(Dmin, D_zeros));
493  const __m128 lt_mask = _mm_or_ps(
494  _mm_cmplt_ps(D, Dmax), _mm_cmpeq_ps(Dmax, D_zeros));
495  // (D>Dmin && D<Dmax) & skip points at zero
496  valid_range_mask =
497  _mm_and_ps(nz_mask, _mm_and_ps(gt_mask, lt_mask));
498  valid_range_mask = _mm_xor_ps(valid_range_mask, xormask);
499  // Add the case of D_min & D_max = 0 (no filtering)
500  valid_range_mask = _mm_or_ps(
501  valid_range_mask, _mm_and_ps(
502  _mm_cmpeq_ps(Dmin, D_zeros),
503  _mm_cmpeq_ps(Dmax, D_zeros)));
504  // Finally, ensure no invalid ranges get thru:
505  valid_range_mask = _mm_and_ps(valid_range_mask, nz_mask);
506  }
507  }
508  const int valid_range_maski = _mm_movemask_epi8(
509  _mm_castps_si128(valid_range_mask)); // 0x{f|0}{f|0}{f|0}{f|0}
510  if (valid_range_maski != 0) // Any of the 4 values is valid?
511  {
512  const __m128 KY = _mm_load_ps(kys);
513  const __m128 KZ = _mm_load_ps(kzs);
514 
515  _mm_storeu_ps(xs, D);
516  _mm_storeu_ps(ys, _mm_mul_ps(KY, D));
517  _mm_storeu_ps(zs, _mm_mul_ps(KZ, D));
518 
519  for (int q = 0; q < 4; q++)
520  {
521  const int actual_c = (c << 2) + q;
522  if ((valid_range_maski & (1 << (q * 4))) != 0)
523  {
524  pca.setPointXYZ(idx, xs[q], ys[q], zs[q]);
525  idxs_x[idx] = actual_c;
526  idxs_y[idx] = r;
527  ++idx;
528  }
529  else
530  {
531  if (MAKE_ORGANIZED)
532  {
533  pca.setInvalidPoint(idx);
534  ++idx;
535  }
536  if (fp.mark_invalid_ranges)
537  rangeImage.coeffRef(r, actual_c) = 0;
538  }
539  }
540  }
541  else if (MAKE_ORGANIZED)
542  {
543  for (int q = 0; q < 4; q++)
544  {
545  pca.setInvalidPoint(idx);
546  ++idx;
547  const int actual_c = (c << 2) + q;
548  if (fp.mark_invalid_ranges)
549  rangeImage.coeffRef(r, actual_c) = 0;
550  }
551  }
552  D_ptr += 4;
553  if (Dgt_ptr) Dgt_ptr += 4;
554  if (Dlt_ptr) Dlt_ptr += 4;
555  kys += 4;
556  kzs += 4;
557  }
558  }
559  pca.resize(idx);
560  // Make sure indices are also resized down to the actual number of points,
561  // even if they are not part of the object PCA refers to:
562  idxs_x.resize(idx);
563  idxs_y.resize(idx);
564 #endif
565 }
566 } // namespace mrpt::obs::detail
mrpt::img::TCamera cameraParams
Projection parameters of the depth camera.
Mainly for internal use within CObservation3DRangeScan::project3DPointsFromDepthImageInto() ...
uint8_t decimation
(Default:1) If !=1, split the range image in blocks of DxD (D=decimation), and only generates one poi...
void resizePoints3DVectors(const size_t nPoints)
Use this method instead of resizing all three points3D_x, points3D_y & points3D_z to allow the usage ...
const mrpt::poses::CPose3D * robotPoseInTheWorld
(Default: nullptr) Read takeIntoAccountSensorPoseOnRobot
double fx() const
Get the value of the focal length x-value (in pixels).
Definition: TCamera.h:161
void do_project_3d_pointcloud_SSE2(const int H, const int W, const float *kys, const float *kzs, mrpt::math::CMatrixF &rangeImage, mrpt::opengl::PointCloudAdapter< POINTMAP > &pca, std::vector< uint16_t > &idxs_x, std::vector< uint16_t > &idxs_y, const mrpt::obs::TRangeImageFilterParams &fp, bool MAKE_ORGANIZED)
mrpt::math::CVectorFixedDouble< 3 > m_coords
The translation vector [x,y,z] access directly or with x(), y(), z() setter/getter methods...
Definition: CPose3D.h:96
const T * ptrLine(unsigned int row) const
Returns a pointer to the first pixel of the given line.
Definition: img/CImage.h:594
An adapter to different kinds of point cloud object.
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3727
std::vector< uint16_t > points3D_idxs_x
If hasPoints3D=true, the (x,y) pixel coordinates for each (X,Y,Z) point in points3D_x, points3D_y, points3D_z.
mrpt::math::CMatrixF rangeImage
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters) ...
void insertMatrix(const int row_start, const int col_start, const OTHERMATVEC &submat)
Copies the given input submatrix/vector into this matrix/vector, starting at the given top-left coord...
Definition: MatrixBase.h:210
double fy() const
Get the value of the focal length y-value (in pixels).
Definition: TCamera.h:163
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement, as from a time-of-flight range camera or any other RGBD sensor.
void range2XYZ(mrpt::opengl::PointCloudAdapter< POINTMAP > &pca, mrpt::obs::CObservation3DRangeScan &src_obs, const mrpt::obs::TRangeImageFilterParams &fp, const int H, const int W)
size_t getHeight() const override
Returns the height of the image in pixels.
Definition: CImage.cpp:877
uint8_t B
Definition: TColor.h:46
uint8_t G
Definition: TColor.h:46
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
unsigned char uint8_t
Definition: rptypes.h:44
const mrpt::math::CMatrixF * rangeMask_max
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
This base provides a set of functions for maths stuff.
size_t getWidth() const override
Returns the width of the image in pixels.
Definition: CImage.cpp:846
mrpt::poses::CPose3D relativePoseIntensityWRTDepth
Relative pose of the intensity camera wrt the depth camera (which is the coordinates origin for this ...
double cy() const
Get the value of the principal point y-coordinate (in pixels).
Definition: TCamera.h:159
An adapter to different kinds of point cloud object.
void composeFrom(const CPose3D &A, const CPose3D &B)
Makes "this = A (+) B"; this method is slightly more efficient than "this= A + B;" since it avoids th...
Definition: CPose3D.cpp:562
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Definition: exceptions.h:137
const GLubyte * c
Definition: glext.h:6406
void project3DPointsFromDepthImageInto(mrpt::obs::CObservation3DRangeScan &src_obs, POINTMAP &dest_pointcloud, const mrpt::obs::T3DPointsProjectionParams &projectParams, const mrpt::obs::TRangeImageFilterParams &filterParams)
mrpt::img::CImage intensityImage
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage"...
bool hasRangeImage
true means the field rangeImage contains valid data
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:108
const mrpt::math::CMatrixF * rangeMask_min
(Default: nullptr) If provided, each data range will be tested to be greater-than (rangeMask_min) or ...
size_type rows() const
Number of rows in the matrix.
size_type cols() const
Number of columns in the matrix.
bool mark_invalid_ranges
If enabled, the range pixels of points that do NOT pass the mask filter will be marked as invalid ran...
uint8_t R
Definition: TColor.h:46
void range2XYZ_LUT(mrpt::opengl::PointCloudAdapter< POINTMAP > &pca, mrpt::obs::CObservation3DRangeScan &src_obs, const mrpt::obs::T3DPointsProjectionParams &pp, const mrpt::obs::TRangeImageFilterParams &fp, const int H, const int W, const int DECIM=1)
const Scalar & coeff(int r, int c) const
bool USE_SSE2
(Default:true) If possible, use SSE2 optimized code.
double cx() const
Get the value of the principal point x-coordinate (in pixels).
Definition: TCamera.h:157
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrixF.h:22
bool MAKE_ORGANIZED
(Default:false) set to true if you want an organized point cloud
GLdouble GLdouble GLdouble r
Definition: glext.h:3711
bool isColor() const
Returns true if the image is RGB, false if it is grayscale.
Definition: CImage.cpp:887
mrpt::poses::CPose3D sensorPose
The 6D pose of the sensor on the robot.
void homogeneousMatrixInverse(const MATRIXLIKE1 &M, MATRIXLIKE2 &out_inverse_M)
Efficiently compute the inverse of a 4x4 homogeneous matrix by only transposing the rotation 3x3 part...
CMatrixFixed< float, ROWS, COLS > cast_float() const
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:84
static TCached3DProjTables & get_3dproj_lut()
3D point cloud projection look-up-table
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
bool hasIntensityImage
true means the field intensityImage contains valid data
bool PROJ3D_USE_LUT
(Default:true) [Only used when range_is_depth=true] Whether to use a Look-up-table (LUT) to speed up ...
bool doDepthAndIntensityCamerasCoincide() const
Return true if relativePoseIntensityWRTDepth equals the pure rotation (0,0,0,-90deg,0,-90deg) (with a small comparison epsilon)
MATRIX44 getHomogeneousMatrixVal() const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
Definition: CPoseOrPoint.h:278
A RGB color - 8bit.
Definition: TColor.h:20
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
Definition: CPose3D.h:224
mrpt::img::TCamera cameraParamsIntensity
Projection parameters of the intensity (graylevel or RGB) camera.
bool range_is_depth
true: Kinect-like ranges: entries of rangeImage are distances along the +X axis; false: Ranges in ran...
bool takeIntoAccountSensorPoseOnRobot
(Default: false) If false, local (sensor-centric) coordinates of points are generated.
Scalar & coeffRef(int r, int c)
bool do_range_filter(size_t r, size_t c, const float D) const
Returns true if the point (r,c) with depth D passes all filters.
bool rangeCheckBetween
Only used if both rangeMask_min and rangeMask_max are present.
void do_project_3d_pointcloud(const int H, const int W, const float *kys, const float *kzs, mrpt::math::CMatrixF &rangeImage, mrpt::opengl::PointCloudAdapter< POINTMAP > &pca, std::vector< uint16_t > &idxs_x, std::vector< uint16_t > &idxs_y, const mrpt::obs::TRangeImageFilterParams &fp, bool MAKE_ORGANIZED, const int DECIM)
int round(const T value)
Returns the closer integer (int) to x.
Definition: round.h:23



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 3316834cb Wed Aug 21 11:42:56 2019 +0200 at miƩ ago 21 11:50:11 CEST 2019