Point cloud library PCL learning: Plane cutting in three-dimensional space (use of PlaneClipper3D)

When using PCL to perform spatial filtering on a point cloud, PassThrough can only achieve the filtering in the direction of the coordinate axis, and PlaneClipper3D can divide the point cloud space with any plane, which is more flexible. Here's how to use it:

Defined function:

pcl::PointCloud<PointT>::Ptr plane_clip(const pcl::PointCloud<PointT>::Ptr& src_cloud, const Eigen::Vector4f& plane, bool negative) 
{
       pcl::PlaneClipper3D<PointT> clipper(plane);
       pcl::PointIndices::Ptr indices(new pcl::PointIndices);
       clipper.clipPointCloud3D(*src_cloud, indices->indices);
       pcl::PointCloud<PointT>::Ptr dst_cloud(new pcl::PointCloud<PointT>);
       pcl::ExtractIndices<PointT> extract;
       extract.setInputCloud(src_cloud);
       extract.setIndices(indices);
       extract.setNegative(negative);
       extract.filter(*dst_cloud);
       return dst_cloud;
}

use:

1. Introduce the header file #include <pcl / filters / plane_clipper3D.h>
2. Call the function, the input parameters are (input point cloud, plane parameters, segmentation direction)

cloud_out = plane_clip(cloud_in, Eigen::Vector4f(1.0,1.0, 1.0,1.0), false);
Published 22 original articles · Likes2 · Visits 1157

Guess you like

Origin blog.csdn.net/qinqinxiansheng/article/details/105492925