Pass Through Filter
pcl::PointCloud<pcl::PointXYZ> passthrough_filter(std::string field, const pcl::PointCloud<pcl::PointXYZ> &input_cloud, double min, double max)
{
pcl::PointCloud<pcl::PointXYZ> output_cloud = input_cloud;
pcl::PassThrough<pcl::PointXYZ> pass;
pass.setFilterFieldName(field);
pass.setFilterLimits(min, max);
pass.setInputCloud(output_cloud.makeShared()); // Set cloud
pass.filter(output_cloud); // Apply the filter
return output_cloud;
}
使用例
cloud = voxelgrid_filter(cloud, 0.02, 0.02, 0.02);
Approximate Voxel Grid Filter
pcl::PointCloud<pcl::PointXYZ> voxelgrid_filter(const pcl::PointCloud<pcl::PointXYZ> &input_cloud, double lx, double ly, double lz)
{
pcl::PointCloud<pcl::PointXYZ> output_cloud = input_cloud;
pcl::ApproximateVoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(output_cloud.makeShared());
sor.setLeafSize(lx, ly, lz);
sor.filter(output_cloud);
return output_cloud;
}
使用例
cloud = passthrough_filter("z", cloud, -0.2, 5.0);