Skip to content

Commit

Permalink
Added statistical outlier removal benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
larshg committed Apr 4, 2024
1 parent 0ed704a commit 45cdd85
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ PCL_ADD_BENCHMARK(filters_voxel_grid FILES filters/voxel_grid.cpp
ARGUMENTS "${PCL_SOURCE_DIR}/test/table_scene_mug_stereo_textured.pcd"
"${PCL_SOURCE_DIR}/test/milk_cartoon_all_small_clorox.pcd")

PCL_ADD_BENCHMARK(filters_statistical_outlier_removal FILES filters/statistical_outlier_removal.cpp
LINK_WITH pcl_io pcl_filters
ARGUMENTS "${PCL_SOURCE_DIR}/test/table_scene_mug_stereo_textured.pcd"
"${PCL_SOURCE_DIR}/test/milk_cartoon_all_small_clorox.pcd")

PCL_ADD_BENCHMARK(search_radius_search FILES search/radius_search.cpp
LINK_WITH pcl_io pcl_search
ARGUMENTS "${PCL_SOURCE_DIR}/test/table_scene_mug_stereo_textured.pcd"
Expand Down
46 changes: 46 additions & 0 deletions benchmarks/filters/statistical_outlier_removal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <pcl/filters/statistical_outlier_removal.h>
#include <pcl/io/pcd_io.h> // for PCDReader

#include <benchmark/benchmark.h>

static void
BM_StatisticalOutlierRemoval(benchmark::State& state, const std::string& file)
{
// Perform setup here
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PCDReader reader;
reader.read(file, *cloud);

pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
sor.setInputCloud(cloud);
sor.setMeanK(50);
sor.setStddevMulThresh(1.0);

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(
new pcl::PointCloud<pcl::PointXYZ>);
for (auto _ : state) {
// This code gets timed
sor.filter(*cloud_filtered);
}
}

int
main(int argc, char** argv)
{
if (argc < 3) {
std::cerr
<< "No test files given. Please download `table_scene_mug_stereo_textured.pcd` "
"and `milk_cartoon_all_small_clorox.pcd`, and pass their paths to the test."
<< std::endl;
return (-1);
}

benchmark::RegisterBenchmark("BM_StatisticalOutlierRemoval_mug", &BM_StatisticalOutlierRemoval, argv[1])
->Unit(benchmark::kMillisecond);
benchmark::RegisterBenchmark(
"BM_StatisticalOutlierRemoval_milk", &BM_StatisticalOutlierRemoval, argv[2])
->Unit(benchmark::kMillisecond);

benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
}

0 comments on commit 45cdd85

Please sign in to comment.