简体   繁体   中英

How to filter all points which are before a given 3d (general) plane in pcl

I'm using pcl to process point cloud data. I want to filter all points which are before a given 3d plane, this plane is defined by pcl::ModelCoefficients (ax + by + cz + d = 0).

Here is the case: when a given plane is placed into point cloud, then surely the cloud will be separated into two parts - before and behind this given 3d plane. There are two similar methods, one is pcl::PassThrough , the other one is pcl::ConditionalRemoval , but I don't know if they can realize my goal?

My question is how to extract all points before that plane? If there is one or more methods, then which one is the effective way?

For now, I figure out one way to do it, but I doubt if it's a effective way.

pcl::ModelCoefficients plane; // given (a,b,c,d) of ax + by + cz + d = 0

pcl::PointCloud<pcl::PointXYZ>::Ptr filtered(new pcl::PointCloud<pcl::PointXYZ>);
for(int i = 0; i < source_point_cloud->points.size(); i++)
{
  PointXYZ point = source_point_cloud->points[i];

  if(point.x * plane.values[0] + point.y * plane.values[1] + point.z *  plane.values[2] +  plane.values[3] > 0)
  {
    filtered->points.push_back(point);
  }
}

Theory is point(x,y,z) on the plane will make formula satisfied:

a * x + b * y + c * z + d = 0;

If a point is before('before the plane' is not clearly defined, but you know what I mean) this plane then we get a inequality:

a * x + b * y + c * z + d > 0;

Otherwise, points are behind the plane.

I had the same issue. Looking in the doc, I found a function called "PlaneClipper3D" that might solve it for future users.

https://pointclouds.org/documentation/classpcl_1_1_plane_clipper3_d.html#ab9550462630a027be9fb42fc250766ab

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM