1. 导入pcd文件
// Declare the original point cloud
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// Read .pcd file
pcl::PCDReader reader;
reader.read<pcl::PointXYZ>("../origin.pcd", *cloud);
std::cout << "PointCloud before filtering has: " << cloud->points.size () << " data points." << std::endl;
2. 移除地面
pcl::VoxelGrid用来滤波,去除杂点
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>), cloud_f (new pcl::PointCloud<pcl::PointXYZ>);
// Create the filtering object: downsampling the dataset using a leaf size of 1cm
pcl::VoxelGrid<pcl::PointXYZ> vg;
vg.setInputCloud(cloud);
vg.setLeafSize(0.01f,0.01f,0.01f);
vg.filter(*cloud_filtered);
std::cout << "PointCloud after filtering has: " << cloud_filtered->points.size () << " data points." << std::endl;
pcl::SACSegmentation 用来做分割。
seg.setModelType (pcl::SACMODEL_PLANE); 设置分割的是平面。
seg.setDistanceThreshold (0.0