@@ -263,7 +263,40 @@ TEST (PCL, PFHEstimation)
263263}
264264
265265// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
266- TEST (PCL, FPFHEstimation)
266+
267+ // "Placeholder" for the type specialized test fixture
268+ template <typename T>
269+ struct FPFHTest ;
270+
271+ // Template specialization test for FPFHEstimation
272+ template <>
273+ struct FPFHTest <FPFHEstimation<PointXYZ, Normal, FPFHSignature33> >
274+ : public ::testing::Test
275+ {
276+ FPFHEstimation<PointXYZ, Normal, FPFHSignature33> fpfh;
277+ };
278+
279+ // Template specialization test for FPFHEstimationOMP
280+ template <>
281+ struct FPFHTest <FPFHEstimationOMP<PointXYZ, Normal, FPFHSignature33> >
282+ : public ::testing::Test
283+ {
284+ // Default Constructor is defined to instantiate 4 threads
285+ FPFHTest<FPFHEstimationOMP<PointXYZ, Normal, FPFHSignature33> > ()
286+ : fpfh (4 )
287+ {}
288+
289+ FPFHEstimationOMP<PointXYZ, Normal, FPFHSignature33> fpfh;
290+ };
291+
292+ // Types which will be instantiated
293+ typedef ::testing::Types<FPFHEstimation<PointXYZ, Normal, FPFHSignature33>,
294+ FPFHEstimationOMP<PointXYZ, Normal, FPFHSignature33> > FPFHEstimatorTypes;
295+ TYPED_TEST_CASE (FPFHTest, FPFHEstimatorTypes);
296+
297+ // This is a copy of the old FPFHEstimation test which will now
298+ // be applied to both FPFHEstimation and FPFHEstimationOMP
299+ TYPED_TEST (FPFHTest, Estimation)
267300{
268301 // Estimate normals first
269302 NormalEstimation<PointXYZ, Normal> n;
@@ -277,7 +310,8 @@ TEST (PCL, FPFHEstimation)
277310 // estimate
278311 n.compute (*normals);
279312
280- FPFHEstimation<PointXYZ, Normal, FPFHSignature33> fpfh;
313+ // Create reference
314+ TypeParam& fpfh = this ->fpfh ;
281315 fpfh.setInputNormals (normals);
282316 EXPECT_EQ (fpfh.getInputNormals (), normals);
283317
@@ -349,8 +383,8 @@ TEST (PCL, FPFHEstimation)
349383 EXPECT_NEAR (fpfh_histogram[15 ], 16.8062 , 1e-2 );
350384 EXPECT_NEAR (fpfh_histogram[16 ], 16.2767 , 1e-2 );
351385 EXPECT_NEAR (fpfh_histogram[17 ], 12.251 , 1e-2 );
352- // EXPECT_NEAR (fpfh_histogram[18], 10.354, 1e-1 );
353- // EXPECT_NEAR (fpfh_histogram[19], 6.65578, 1e-2);
386+ EXPECT_NEAR (fpfh_histogram[18 ], 10.354 , 1e-2 );
387+ EXPECT_NEAR (fpfh_histogram[19 ], 6.65578 , 1e-2 );
354388 EXPECT_NEAR (fpfh_histogram[20 ], 6.1437 , 1e-2 );
355389 EXPECT_NEAR (fpfh_histogram[21 ], 5.83341 , 1e-2 );
356390 EXPECT_NEAR (fpfh_histogram[22 ], 1.08809 , 1e-2 );
@@ -397,8 +431,8 @@ TEST (PCL, FPFHEstimation)
397431 EXPECT_NEAR (fpfhs->points [0 ].histogram [15 ], 17.963 , 1e-2 );
398432 EXPECT_NEAR (fpfhs->points [0 ].histogram [16 ], 18.2801 , 1e-2 );
399433 EXPECT_NEAR (fpfhs->points [0 ].histogram [17 ], 14.2766 , 1e-2 );
400- // EXPECT_NEAR (fpfhs->points[0].histogram[18], 10.8542, 1e-2);
401- // EXPECT_NEAR (fpfhs->points[0].histogram[19], 6.07925, 1e-2);
434+ EXPECT_NEAR (fpfhs->points [0 ].histogram [18 ], 10.8542 , 1e-2 );
435+ EXPECT_NEAR (fpfhs->points [0 ].histogram [19 ], 6.07925 , 1e-2 );
402436 EXPECT_NEAR (fpfhs->points [0 ].histogram [20 ], 5.28565 , 1e-2 );
403437 EXPECT_NEAR (fpfhs->points [0 ].histogram [21 ], 4.73887 , 1e-2 );
404438 EXPECT_NEAR (fpfhs->points [0 ].histogram [22 ], 0.56984 , 1e-2 );
@@ -421,83 +455,8 @@ TEST (PCL, FPFHEstimation)
421455
422456 testIndicesAndSearchSurface<FPFHEstimation<PointXYZ, Normal, FPFHSignature33>, PointXYZ, Normal, FPFHSignature33>
423457 (cloud.makeShared (), normals, test_indices, 33 );
424-
425458}
426459
427- // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
428- TEST (PCL, FPFHEstimationOpenMP)
429- {
430- // Estimate normals first
431- NormalEstimation<PointXYZ, Normal> n;
432- PointCloud<Normal>::Ptr normals (new PointCloud<Normal> ());
433- // set parameters
434- n.setInputCloud (cloud.makeShared ());
435- boost::shared_ptr<vector<int > > indicesptr (new vector<int > (indices));
436- n.setIndices (indicesptr);
437- n.setSearchMethod (tree);
438- n.setKSearch (10 ); // Use 10 nearest neighbors to estimate the normals
439- // estimate
440- n.compute (*normals);
441- FPFHEstimationOMP<PointXYZ, Normal, FPFHSignature33> fpfh (4 ); // instantiate 4 threads
442- fpfh.setInputNormals (normals);
443-
444- // Object
445- PointCloud<FPFHSignature33>::Ptr fpfhs (new PointCloud<FPFHSignature33> ());
446-
447- // set parameters
448- fpfh.setInputCloud (cloud.makeShared ());
449- fpfh.setNrSubdivisions (11 , 11 , 11 );
450- fpfh.setIndices (indicesptr);
451- fpfh.setSearchMethod (tree);
452- fpfh.setKSearch (static_cast <int > (indices.size ()));
453-
454- // estimate
455- fpfh.compute (*fpfhs);
456- EXPECT_EQ (fpfhs->points .size (), indices.size ());
457-
458- EXPECT_NEAR (fpfhs->points [0 ].histogram [0 ], 1.58591 , 1e-3 );
459- EXPECT_NEAR (fpfhs->points [0 ].histogram [1 ], 1.68365 , 1e-2 );
460- EXPECT_NEAR (fpfhs->points [0 ].histogram [2 ], 6.71 , 1e-3 );
461- EXPECT_NEAR (fpfhs->points [0 ].histogram [3 ], 23.073 , 1e-3 );
462- EXPECT_NEAR (fpfhs->points [0 ].histogram [4 ], 33.3828 , 1e-2 );
463- EXPECT_NEAR (fpfhs->points [0 ].histogram [5 ], 20.4002 , 1e-3 );
464- EXPECT_NEAR (fpfhs->points [0 ].histogram [6 ], 7.31067 , 1e-3 );
465- EXPECT_NEAR (fpfhs->points [0 ].histogram [7 ], 1.02635 , 1e-3 );
466- EXPECT_NEAR (fpfhs->points [0 ].histogram [8 ], 0.48591 , 1e-3 );
467- EXPECT_NEAR (fpfhs->points [0 ].histogram [9 ], 1.47069 , 1e-2 );
468- EXPECT_NEAR (fpfhs->points [0 ].histogram [10 ], 2.87061 , 1e-3 );
469- EXPECT_NEAR (fpfhs->points [0 ].histogram [11 ], 1.78321 , 1e-3 );
470- EXPECT_NEAR (fpfhs->points [0 ].histogram [12 ], 4.30795 , 1e-3 );
471- EXPECT_NEAR (fpfhs->points [0 ].histogram [13 ], 7.05514 , 1e-3 );
472- EXPECT_NEAR (fpfhs->points [0 ].histogram [14 ], 9.37615 , 1e-3 );
473- EXPECT_NEAR (fpfhs->points [0 ].histogram [15 ], 17.963 , 1e-3 );
474- // EXPECT_NEAR (fpfhs->points[0].histogram[16], 18.2801, 1e-3);
475- // EXPECT_NEAR (fpfhs->points[0].histogram[17], 14.2766, 1e-3);
476- // EXPECT_NEAR (fpfhs->points[0].histogram[18], 10.8542, 1e-3);
477- // EXPECT_NEAR (fpfhs->points[0].histogram[19], 6.07925, 1e-3);
478- EXPECT_NEAR (fpfhs->points [0 ].histogram [20 ], 5.28991 , 1e-3 );
479- EXPECT_NEAR (fpfhs->points [0 ].histogram [21 ], 4.73438 , 1e-3 );
480- EXPECT_NEAR (fpfhs->points [0 ].histogram [22 ], 0.56984 , 1e-3 );
481- EXPECT_NEAR (fpfhs->points [0 ].histogram [23 ], 3.29826 , 1e-3 );
482- EXPECT_NEAR (fpfhs->points [0 ].histogram [24 ], 5.28156 , 1e-3 );
483- EXPECT_NEAR (fpfhs->points [0 ].histogram [25 ], 5.26939 , 1e-2 );
484- EXPECT_NEAR (fpfhs->points [0 ].histogram [26 ], 3.13191 , 1e-3 );
485- EXPECT_NEAR (fpfhs->points [0 ].histogram [27 ], 1.74453 , 1e-3 );
486- EXPECT_NEAR (fpfhs->points [0 ].histogram [28 ], 9.41971 , 1e-3 );
487- EXPECT_NEAR (fpfhs->points [0 ].histogram [29 ], 21.5894 , 1e-2 );
488- EXPECT_NEAR (fpfhs->points [0 ].histogram [30 ], 24.6302 , 1e-3 );
489- EXPECT_NEAR (fpfhs->points [0 ].histogram [31 ], 17.7764 , 1e-3 );
490- EXPECT_NEAR (fpfhs->points [0 ].histogram [32 ], 7.28878 , 1e-3 );
491-
492- // Test results when setIndices and/or setSearchSurface are used
493-
494- boost::shared_ptr<vector<int > > test_indices (new vector<int > (0 ));
495- for (size_t i = 0 ; i < cloud.size (); i+=3 )
496- test_indices->push_back (static_cast <int > (i));
497-
498- testIndicesAndSearchSurface<FPFHEstimationOMP<PointXYZ, Normal, FPFHSignature33>, PointXYZ, Normal, FPFHSignature33>
499- (cloud.makeShared (), normals, test_indices, 33 );
500- }
501460
502461// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
503462TEST (PCL, VFHEstimation)
0 commit comments