Main MRPT website > C++ reference for MRPT 1.5.5
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 { namespace utils {
20  }
21 }
22 
23 #define TEST_RANGEIMG_WIDTH 32
24 #define TEST_RANGEIMG_HEIGHT 24
25 
27 {
28  obs.hasRangeImage = true;
30 
31  obs.rangeImage.setZero();
32 
33  for (int r=10;r<16;r++)
34  for (int c=10;c<=r;c++)
35  obs.rangeImage(r,c) = r;
36 
37  // Test case:
38  pp.PROJ3D_USE_LUT = (test_case&1)!=0;
39  pp.USE_SSE2 = (test_case&2)!=0;
40  pp.takeIntoAccountSensorPoseOnRobot = (test_case&4)!=0;
41 }
42 
43 
44 TEST(CObservation3DRangeScan, Project3D_noFilter)
45 {
48 
49  for (int i=0;i<8;i++) // test all combinations of flags
50  {
52  fillSampleObs(o,pp,i);
53 
55  EXPECT_EQ(o.points3D_x.size(),21U) << " testcase flags: i=" << i << std::endl;
56  }
57 }
58 
59 TEST(CObservation3DRangeScan, Project3D_filterMinMax1)
60 {
62  fMin(12,12) = 11.5f; fMax(12,12) = 12.5f; // pass
63  fMin(14,14) = 15.5f; fMax(14,14) = 16.5f; // don't pass
64  // Rest of points: filter=0.0f -> no filtering
65 
68  fp.rangeMask_min = &fMin;
69  fp.rangeMask_max = &fMax;
70 
71  for (int i=0;i<16;i++) // test all combinations of flags
72  {
74  fillSampleObs(o,pp,i);
75  fp.rangeCheckBetween = (i&8)!=0;
76 
78  EXPECT_EQ(o.points3D_x.size(),20U) << " testcase flags: i=" << i << std::endl;
79  }
80 }
81 
82 TEST(CObservation3DRangeScan, Project3D_filterMinMaxAllBetween)
83 {
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 ) << " testcase flags: i=" << i << std::endl;
106  }
107 }
108 
109 
110 TEST(CObservation3DRangeScan, Project3D_filterMinMaxNoneBetween)
111 {
113  // Default filter=0.0f -> no filtering
114  for (int r=10;r<16;r++)
115  for (int c=10;c<16;c++)
116  {
117  fMin(r,c) = r+1.1f; // No point lies in between
118  fMax(r,c) = r+1.2f;
119  }
120 
123  fp.rangeMask_min = &fMin;
124  fp.rangeMask_max = &fMax;
125 
126  for (int i=0;i<16;i++) // test all combinations of flags
127  {
129  fillSampleObs(o,pp,i);
130  fp.rangeCheckBetween = (i&8)!=0;
131 
133  EXPECT_EQ(o.points3D_x.size(),fp.rangeCheckBetween ? 0U:21U ) << " testcase flags: i=" << i << std::endl;
134  }
135 }
136 
137 TEST(CObservation3DRangeScan, Project3D_filterMin)
138 {
140  // Default filter=0.0f -> no filtering
141  for (int r=10;r<16;r++)
142  for (int c=10;c<16;c++)
143  fMin(r,c) = 14.5f; // Only last row of points should pass this filter
144 
147  fp.rangeMask_min = &fMin;
148 
149  for (int i=0;i<8;i++) // test all combinations of flags
150  {
152  fillSampleObs(o,pp,i);
153 
155  EXPECT_EQ(o.points3D_x.size(), 6U ) << " testcase flags: i=" << i << std::endl;
156  }
157 }
158 
159 TEST(CObservation3DRangeScan, Project3D_filterMax)
160 {
162  // Default filter=0.0f -> no filtering
163  for (int r=10;r<16;r++)
164  for (int c=10;c<16;c++)
165  fMax(r,c) = 11.5f; // Only first 2 rows of points should pass this filter
166 
169  fp.rangeMask_max = &fMax;
170 
171  for (int i=0;i<8;i++) // test all combinations of flags
172  {
174  fillSampleObs(o,pp,i);
175 
177  EXPECT_EQ(o.points3D_x.size(), 3U ) << " testcase flags: i=" << i << std::endl;
178  }
179 }
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: NULL) If provided, each data range will be tested to be greater-than (rangeMask_min) or les...
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:5590
bool hasRangeImage
true means the field rangeImage contains valid data
GLsizei const GLchar ** string
Definition: glext.h:3919
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:3618
const mrpt::math::CMatrix * rangeMask_max
Used in CObservation3DRangeScan::project3DPointsFromDepthImageInto()
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:30
bool takeIntoAccountSensorPoseOnRobot
(Default: false) If false, local (sensor-centric) coordinates of points are generated. Otherwise, points are transformed with sensorPose. Furthermore, if provided, those coordinates are transformed with robotPoseInTheWorld
bool rangeCheckBetween
Only used if both rangeMask_min and rangeMask_max are present.



Page generated by Doxygen 1.8.14 for MRPT 1.5.5 Git: e06b63dbf Fri Dec 1 14:41:11 2017 +0100 at lun oct 28 01:31:35 CET 2019