马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
下载数据集 table_scene_lms400.pcd 并将其保存到磁盘的某个位置。
然后,创建一个文件,好比说,在你的收藏夹中 编辑器,并将以下内容放入此中:statistical_removal.cpp
- #include <iostream>
- #include <pcl/io/pcd_io.h>
- #include <pcl/point_types.h>
- #include <pcl/filters/statistical_outlier_removal.h>
- int
- main ()
- {
- pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
- pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);
- // Fill in the cloud data
- pcl::PCDReader reader;
- // Replace the path below with the path where you saved your file
- reader.read<pcl::PointXYZ> ("table_scene_lms400.pcd", *cloud);
- std::cerr << "Cloud before filtering: " << std::endl;
- std::cerr << *cloud << std::endl;
- // Create the filtering object
- pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
- sor.setInputCloud (cloud);
- sor.setMeanK (50);
- sor.setStddevMulThresh (1.0);
- sor.filter (*cloud_filtered);
- std::cerr << "Cloud after filtering: " << std::endl;
- std::cerr << *cloud_filtered << std::endl;
- pcl::PCDWriter writer;
- writer.write<pcl::PointXYZ> ("table_scene_lms400_inliers.pcd", *cloud_filtered, false);
- sor.setNegative (true);
- sor.filter (*cloud_filtered);
- writer.write<pcl::PointXYZ> ("table_scene_lms400_outliers.pcd", *cloud_filtered, false);
- return (0);
- }
复制代码 编译和运行步伐
将以下行添加到您的 CMakeLists.txt 文件中
- cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
- project(statistical_removal)
- find_package(PCL 1.2 REQUIRED)
- include_directories(${PCL_INCLUDE_DIRS})
- link_directories(${PCL_LIBRARY_DIRS})
- add_definitions(${PCL_DEFINITIONS})
- add_executable (statistical_removal statistical_removal.cpp)
- target_link_libraries (statistical_removal ${PCL_LIBRARIES})
复制代码 创建可执行文件后,您可以运行它。只需:
您将看到类似于以下内容的内容:
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |