11#include < pcl/features/normal_3d_omp.h>
22#include < pcl/features/shot_omp.h>
3+ #include < pcl/filters/uniform_sampling.h>
34#include < pcl/io/pcd_io.h>
45#include < pcl/point_cloud.h>
56#include < pcl/point_types.h>
67
78#include < benchmark/benchmark.h>
89
10+ constexpr float lrf_radius = 0 .04f ;
11+ constexpr float shot_search_radius = 0 .04f ;
12+ constexpr float uniform_sampling_radius = 0 .03f ;
13+
914static void
1015BM_SHOT352 (benchmark::State& state, const std::string& file)
1116{
@@ -19,10 +24,18 @@ BM_SHOT352(benchmark::State& state, const std::string& file)
1924 pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
2025 ne.compute (*normals);
2126
27+ pcl::UniformSampling<pcl::PointXYZ> uniform_sampling;
28+ uniform_sampling.setInputCloud (cloud);
29+ uniform_sampling.setRadiusSearch (uniform_sampling_radius);
30+ pcl::PointCloud<pcl::PointXYZ>::Ptr keypoints (new pcl::PointCloud<pcl::PointXYZ>);
31+ uniform_sampling.filter (*keypoints);
32+
2233 pcl::SHOTEstimation<pcl::PointXYZ, pcl::Normal, pcl::SHOT352> shot;
23- shot.setInputCloud (cloud );
34+ shot.setInputCloud (keypoints );
2435 shot.setInputNormals (normals);
25- shot.setRadiusSearch (0.04 );
36+ shot.setSearchSurface (cloud);
37+ shot.setRadiusSearch (shot_search_radius);
38+ shot.setLRFRadius (lrf_radius);
2639
2740 pcl::PointCloud<pcl::SHOT352>::Ptr output (new pcl::PointCloud<pcl::SHOT352>);
2841 for (auto _ : state) {
@@ -43,12 +56,20 @@ BM_SHOT352_OMP(benchmark::State& state, const std::string& file)
4356 pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
4457 ne.compute (*normals);
4558
59+ pcl::UniformSampling<pcl::PointXYZ> uniform_sampling;
60+ uniform_sampling.setInputCloud (cloud);
61+ uniform_sampling.setRadiusSearch (uniform_sampling_radius);
62+ pcl::PointCloud<pcl::PointXYZ>::Ptr keypoints (new pcl::PointCloud<pcl::PointXYZ>);
63+ uniform_sampling.filter (*keypoints);
64+
4665 pcl::SHOTEstimationOMP<pcl::PointXYZ, pcl::Normal, pcl::SHOT352> shot (
4766 0 , state.range (0 ) //
4867 );
49- shot.setInputCloud (cloud );
68+ shot.setInputCloud (keypoints );
5069 shot.setInputNormals (normals);
51- shot.setRadiusSearch (0.04 );
70+ shot.setSearchSurface (cloud);
71+ shot.setRadiusSearch (shot_search_radius);
72+ shot.setLRFRadius (lrf_radius);
5273
5374 pcl::PointCloud<pcl::SHOT352>::Ptr output (new pcl::PointCloud<pcl::SHOT352>);
5475 for (auto _ : state) {
@@ -59,34 +80,31 @@ BM_SHOT352_OMP(benchmark::State& state, const std::string& file)
5980static void
6081BM_SHOT1344 (benchmark::State& state, const std::string& file)
6182{
62- pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_xyz (new pcl::PointCloud<pcl::PointXYZ>);
83+ pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_rgba (
84+ new pcl::PointCloud<pcl::PointXYZRGBA>);
6385 pcl::PCDReader reader;
64- reader.read (file, *cloud_xyz );
86+ reader.read (file, *cloud_rgba );
6587
66- pcl::NormalEstimationOMP<pcl::PointXYZ , pcl::Normal> ne;
67- ne.setInputCloud (cloud_xyz );
88+ pcl::NormalEstimationOMP<pcl::PointXYZRGBA , pcl::Normal> ne;
89+ ne.setInputCloud (cloud_rgba );
6890 ne.setKSearch (10 );
6991 pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
7092 ne.compute (*normals);
7193
72- pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_rgba (
94+ pcl::UniformSampling<pcl::PointXYZRGBA> uniform_sampling;
95+ uniform_sampling.setInputCloud (cloud_rgba);
96+ uniform_sampling.setRadiusSearch (uniform_sampling_radius);
97+ pcl::PointCloud<pcl::PointXYZRGBA>::Ptr keypoints (
7398 new pcl::PointCloud<pcl::PointXYZRGBA>);
74-
75- for (int i = 0 ; i < static_cast <int >(cloud_xyz->size ()); ++i) {
76- pcl::PointXYZRGBA p;
77- p.x = (*cloud_xyz)[i].x ;
78- p.y = (*cloud_xyz)[i].y ;
79- p.z = (*cloud_xyz)[i].z ;
80-
81- p.rgba = ((i % 255 ) << 16 ) + (((255 - i) % 255 ) << 8 ) + ((i * 37 ) % 255 );
82- cloud_rgba->push_back (p);
83- }
99+ uniform_sampling.filter (*keypoints);
84100
85101 pcl::SHOTColorEstimation<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT1344> shot (true ,
86102 true );
87- shot.setInputCloud (cloud_rgba );
103+ shot.setInputCloud (keypoints );
88104 shot.setInputNormals (normals);
89- shot.setRadiusSearch (0.04 );
105+ shot.setSearchSurface (cloud_rgba);
106+ shot.setRadiusSearch (shot_search_radius);
107+ shot.setLRFRadius (lrf_radius);
90108
91109 pcl::PointCloud<pcl::SHOT1344>::Ptr output (new pcl::PointCloud<pcl::SHOT1344>);
92110 for (auto _ : state) {
@@ -97,34 +115,31 @@ BM_SHOT1344(benchmark::State& state, const std::string& file)
97115static void
98116BM_SHOT1344_OMP (benchmark::State& state, const std::string& file)
99117{
100- pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_xyz (new pcl::PointCloud<pcl::PointXYZ>);
118+ pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_rgba (
119+ new pcl::PointCloud<pcl::PointXYZRGBA>);
101120 pcl::PCDReader reader;
102- reader.read (file, *cloud_xyz );
121+ reader.read (file, *cloud_rgba );
103122
104- pcl::NormalEstimationOMP<pcl::PointXYZ , pcl::Normal> ne;
105- ne.setInputCloud (cloud_xyz );
123+ pcl::NormalEstimationOMP<pcl::PointXYZRGBA , pcl::Normal> ne;
124+ ne.setInputCloud (cloud_rgba );
106125 ne.setKSearch (10 );
107126 pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
108127 ne.compute (*normals);
109128
110- pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_rgba (
129+ pcl::UniformSampling<pcl::PointXYZRGBA> uniform_sampling;
130+ uniform_sampling.setInputCloud (cloud_rgba);
131+ uniform_sampling.setRadiusSearch (uniform_sampling_radius);
132+ pcl::PointCloud<pcl::PointXYZRGBA>::Ptr keypoints (
111133 new pcl::PointCloud<pcl::PointXYZRGBA>);
112-
113- for (int i = 0 ; i < static_cast <int >(cloud_xyz->size ()); ++i) {
114- pcl::PointXYZRGBA p;
115- p.x = (*cloud_xyz)[i].x ;
116- p.y = (*cloud_xyz)[i].y ;
117- p.z = (*cloud_xyz)[i].z ;
118-
119- p.rgba = ((i % 255 ) << 16 ) + (((255 - i) % 255 ) << 8 ) + ((i * 37 ) % 255 );
120- cloud_rgba->push_back (p);
121- }
134+ uniform_sampling.filter (*keypoints);
122135
123136 pcl::SHOTColorEstimationOMP<pcl::PointXYZRGBA, pcl::Normal, pcl::SHOT1344> shot (
124137 true , true , 0 , state.range (0 ));
125- shot.setInputCloud (cloud_rgba );
138+ shot.setInputCloud (keypoints );
126139 shot.setInputNormals (normals);
127- shot.setRadiusSearch (0.04 );
140+ shot.setSearchSurface (cloud_rgba);
141+ shot.setRadiusSearch (shot_search_radius);
142+ shot.setLRFRadius (lrf_radius);
128143
129144 pcl::PointCloud<pcl::SHOT1344>::Ptr output (new pcl::PointCloud<pcl::SHOT1344>);
130145 for (auto _ : state) {
0 commit comments