MRPT  1.9.9
CObservation3DRangeScan_unittest.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 
11 
12 #include <gtest/gtest.h>
13 
14 using namespace mrpt;
15 using namespace std;
16 
17 #define TEST_RANGEIMG_WIDTH 32
18 #define TEST_RANGEIMG_HEIGHT 24
19 
22  mrpt::obs::T3DPointsProjectionParams& pp, int test_case)
23 {
24  obs.hasRangeImage = true;
26 
27  obs.rangeImage.setZero();
28 
29  for (int r = 10; r < 16; r++)
30  for (int c = 10; c <= r; c++) obs.rangeImage(r, c) = r;
31 
32  // Test case:
33  pp.PROJ3D_USE_LUT = (test_case & 1) != 0;
34  pp.USE_SSE2 = (test_case & 2) != 0;
35  pp.takeIntoAccountSensorPoseOnRobot = (test_case & 4) != 0;
36 }
37 
38 TEST(CObservation3DRangeScan, Project3D_noFilter)
39 {
42 
43  for (int i = 0; i < 8; i++) // test all combinations of flags
44  {
46  fillSampleObs(o, pp, i);
47 
49  EXPECT_EQ(o.points3D_x.size(), 21U) << " testcase flags: i=" << i
50  << std::endl;
51  }
52 }
53 
54 TEST(CObservation3DRangeScan, Project3D_filterMinMax1)
55 {
58  fMin(12, 12) = 11.5f;
59  fMax(12, 12) = 12.5f; // pass
60  fMin(14, 14) = 15.5f;
61  fMax(14, 14) = 16.5f; // don't pass
62  // Rest of points: filter=0.0f -> no filtering
63 
66  fp.rangeMask_min = &fMin;
67  fp.rangeMask_max = &fMax;
68 
69  for (int i = 0; i < 16; i++) // test all combinations of flags
70  {
72  fillSampleObs(o, pp, i);
73  fp.rangeCheckBetween = (i & 8) != 0;
74 
76  EXPECT_EQ(o.points3D_x.size(), 20U) << " testcase flags: i=" << i
77  << std::endl;
78  }
79 }
80 
81 TEST(CObservation3DRangeScan, Project3D_filterMinMaxAllBetween)
82 {
85  // Default filter=0.0f -> no filtering
86  for (int r = 10; r < 16; r++)
87  for (int c = 10; c < 16; c++)
88  {
89  fMin(r, c) = r - 0.1f; // All points actually lie in between
90  fMax(r, c) = r + 0.1f;
91  }
92 
95  fp.rangeMask_min = &fMin;
96  fp.rangeMask_max = &fMax;
97 
98  for (int i = 0; i < 16; i++) // test all combinations of flags
99  {
101  fillSampleObs(o, pp, i);
102  fp.rangeCheckBetween = (i & 8) != 0;
103 
105  EXPECT_EQ(o.points3D_x.size(), fp.rangeCheckBetween ? 21U : 0U)
106  << " testcase flags: i=" << i << std::endl;
107  }
108 }
109 
110 TEST(CObservation3DRangeScan, Project3D_filterMinMaxNoneBetween)
111 {
114  // Default filter=0.0f -> no filtering
115  for (int r = 10; r < 16; r++)
116  for (int c = 10; c < 16; c++)
117  {
118  fMin(r, c) = r + 1.1f; // No point lies in between
119  fMax(r, c) = r + 1.2f;
120  }
121 
124  fp.rangeMask_min = &fMin;
125  fp.rangeMask_max = &fMax;
126 
127  for (int i = 0; i < 16; i++) // test all combinations of flags
128  {
130  fillSampleObs(o, pp, i);
131  fp.rangeCheckBetween = (i & 8) != 0;
132 
134  EXPECT_EQ(o.points3D_x.size(), fp.rangeCheckBetween ? 0U : 21U)
135  << " testcase flags: i=" << i << std::endl;
136  }
137 }
138 
139 TEST(CObservation3DRangeScan, Project3D_filterMin)
140 {
142  // Default filter=0.0f -> no filtering
143  for (int r = 10; r < 16; r++)
144  for (int c = 10; c < 16; c++)
145  fMin(r, c) =
146  14.5f; // Only last row of points should pass this filter
147 
150  fp.rangeMask_min = &fMin;
151 
152  for (int i = 0; i < 8; i++) // test all combinations of flags
153  {
155  fillSampleObs(o, pp, i);
156 
158  EXPECT_EQ(o.points3D_x.size(), 6U) << " testcase flags: i=" << i
159  << std::endl;
160  }
161 }
162 
163 TEST(CObservation3DRangeScan, Project3D_filterMax)
164 {
166  // Default filter=0.0f -> no filtering
167  for (int r = 10; r < 16; r++)
168  for (int c = 10; c < 16; c++)
169  fMax(r, c) =
170  11.5f; // Only first 2 rows of points should pass this filter
171 
174  fp.rangeMask_max = &fMax;
175 
176  for (int i = 0; i < 8; i++) // test all combinations of flags
177  {
179  fillSampleObs(o, pp, i);
180 
182  EXPECT_EQ(o.points3D_x.size(), 3U) << " testcase flags: i=" << i
183  << std::endl;
184  }
185 }
void fillSampleObs(mrpt::obs::CObservation3DRangeScan &obs, mrpt::obs::T3DPointsProjectionParams &pp, int test_case)
#define TEST_RANGEIMG_WIDTH
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.
const mrpt::math::CMatrix * rangeMask_min
(Default: nullptr) If provided, each data range will be tested to be greater-than (rangeMask_min) or ...
STL namespace.
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
TEST(CObservation3DRangeScan, Project3D_noFilter)
mrpt::math::CMatrix rangeImage
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters) ...
#define TEST_RANGEIMG_HEIGHT
const GLubyte * c
Definition: glext.h:6313
bool hasRangeImage
true means the field rangeImage contains valid data
bool USE_SSE2
(Default:true) If possible, use SSE2 optimized code.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
const mrpt::math::CMatrix * rangeMask_max
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
std::vector< float > points3D_x
If hasPoints3D=true, the (X,Y,Z) coordinates of the 3D point cloud detected by the camera...
void rangeImage_setSize(const int HEIGHT, const int WIDTH)
Similar to calling "rangeImage.setSize(H,W)" but this method provides memory pooling to speed-up the ...
void project3DPointsFromDepthImageInto(POINTMAP &dest_pointcloud, const T3DPointsProjectionParams &projectParams, const TRangeImageFilterParams &filterParams=TRangeImageFilterParams())
Project the RGB+D images into a 3D point cloud (with color if the target map supports it) and optiona...
bool PROJ3D_USE_LUT
(Default:true) [Only used when range_is_depth=true] Whether to use a Look-up-table (LUT) to speed up ...
This class is a "CSerializable" wrapper for "CMatrixFloat".
Definition: CMatrix.h:22
bool takeIntoAccountSensorPoseOnRobot
(Default: false) If false, local (sensor-centric) coordinates of points are generated.
bool rangeCheckBetween
Only used if both rangeMask_min and rangeMask_max are present.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020