Main MRPT website > C++ reference for 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-2017, 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 // Defined in tests/test_main.cpp
18 namespace mrpt
19 {
20 namespace utils
21 {
23 }
24 }
25 
26 #define TEST_RANGEIMG_WIDTH 32
27 #define TEST_RANGEIMG_HEIGHT 24
28 
31  mrpt::obs::T3DPointsProjectionParams& pp, int test_case)
32 {
33  obs.hasRangeImage = true;
35 
36  obs.rangeImage.setZero();
37 
38  for (int r = 10; r < 16; r++)
39  for (int c = 10; c <= r; c++) obs.rangeImage(r, c) = r;
40 
41  // Test case:
42  pp.PROJ3D_USE_LUT = (test_case & 1) != 0;
43  pp.USE_SSE2 = (test_case & 2) != 0;
44  pp.takeIntoAccountSensorPoseOnRobot = (test_case & 4) != 0;
45 }
46 
47 TEST(CObservation3DRangeScan, Project3D_noFilter)
48 {
51 
52  for (int i = 0; i < 8; i++) // test all combinations of flags
53  {
55  fillSampleObs(o, pp, i);
56 
58  EXPECT_EQ(o.points3D_x.size(), 21U) << " testcase flags: i=" << i
59  << std::endl;
60  }
61 }
62 
63 TEST(CObservation3DRangeScan, Project3D_filterMinMax1)
64 {
67  fMin(12, 12) = 11.5f;
68  fMax(12, 12) = 12.5f; // pass
69  fMin(14, 14) = 15.5f;
70  fMax(14, 14) = 16.5f; // don't pass
71  // Rest of points: filter=0.0f -> no filtering
72 
75  fp.rangeMask_min = &fMin;
76  fp.rangeMask_max = &fMax;
77 
78  for (int i = 0; i < 16; i++) // test all combinations of flags
79  {
81  fillSampleObs(o, pp, i);
82  fp.rangeCheckBetween = (i & 8) != 0;
83 
85  EXPECT_EQ(o.points3D_x.size(), 20U) << " testcase flags: i=" << i
86  << std::endl;
87  }
88 }
89 
90 TEST(CObservation3DRangeScan, Project3D_filterMinMaxAllBetween)
91 {
94  // Default filter=0.0f -> no filtering
95  for (int r = 10; r < 16; r++)
96  for (int c = 10; c < 16; c++)
97  {
98  fMin(r, c) = r - 0.1f; // All points actually lie in between
99  fMax(r, c) = r + 0.1f;
100  }
101 
104  fp.rangeMask_min = &fMin;
105  fp.rangeMask_max = &fMax;
106 
107  for (int i = 0; i < 16; i++) // test all combinations of flags
108  {
110  fillSampleObs(o, pp, i);
111  fp.rangeCheckBetween = (i & 8) != 0;
112 
114  EXPECT_EQ(o.points3D_x.size(), fp.rangeCheckBetween ? 21U : 0U)
115  << " testcase flags: i=" << i << std::endl;
116  }
117 }
118 
119 TEST(CObservation3DRangeScan, Project3D_filterMinMaxNoneBetween)
120 {
123  // Default filter=0.0f -> no filtering
124  for (int r = 10; r < 16; r++)
125  for (int c = 10; c < 16; c++)
126  {
127  fMin(r, c) = r + 1.1f; // No point lies in between
128  fMax(r, c) = r + 1.2f;
129  }
130 
133  fp.rangeMask_min = &fMin;
134  fp.rangeMask_max = &fMax;
135 
136  for (int i = 0; i < 16; i++) // test all combinations of flags
137  {
139  fillSampleObs(o, pp, i);
140  fp.rangeCheckBetween = (i & 8) != 0;
141 
143  EXPECT_EQ(o.points3D_x.size(), fp.rangeCheckBetween ? 0U : 21U)
144  << " testcase flags: i=" << i << std::endl;
145  }
146 }
147 
148 TEST(CObservation3DRangeScan, Project3D_filterMin)
149 {
151  // Default filter=0.0f -> no filtering
152  for (int r = 10; r < 16; r++)
153  for (int c = 10; c < 16; c++)
154  fMin(r, c) =
155  14.5f; // Only last row of points should pass this filter
156 
159  fp.rangeMask_min = &fMin;
160 
161  for (int i = 0; i < 8; i++) // test all combinations of flags
162  {
164  fillSampleObs(o, pp, i);
165 
167  EXPECT_EQ(o.points3D_x.size(), 6U) << " testcase flags: i=" << i
168  << std::endl;
169  }
170 }
171 
172 TEST(CObservation3DRangeScan, Project3D_filterMax)
173 {
175  // Default filter=0.0f -> no filtering
176  for (int r = 10; r < 16; r++)
177  for (int c = 10; c < 16; c++)
178  fMax(r, c) =
179  11.5f; // Only first 2 rows of points should pass this filter
180 
183  fp.rangeMask_max = &fMax;
184 
185  for (int i = 0; i < 8; i++) // test all combinations of flags
186  {
188  fillSampleObs(o, pp, i);
189 
191  EXPECT_EQ(o.points3D_x.size(), 3U) << " testcase flags: i=" << i
192  << std::endl;
193  }
194 }
void fillSampleObs(mrpt::obs::CObservation3DRangeScan &obs, mrpt::obs::T3DPointsProjectionParams &pp, int test_case)
#define TEST_RANGEIMG_WIDTH
std::string MRPT_GLOBAL_UNITTEST_SRC_DIR
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
GLsizei const GLchar ** string
Definition: glext.h:4101
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:25
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: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019