Abhishek V
Abhishek V

Reputation: 21

Remove points in one point cloud from another in PCL?

Let's say I have two point clouds A and B. I want to do the following operation: C=A-B where C is the output cloud of the operation. I'm aware PCL has the '+' operation for concatenating two point clouds like:

  pcl::PointCloud<pcl::PointXYZ> A;
  pcl::PointCloud<pcl::PointXYZ> B; //assume A and B have points in them
  pcl::PointCloud<pcl::PointXYZ> C = A+B;

However I don't think there's a '-' operator for removing points in one point cloud from another.

Can I create hash map for A and B? The output C has only points which appear once in the hash map. Or is there a better way to do this?

Upvotes: 2

Views: 2190

Answers (1)

Dexter
Dexter

Reputation: 2480

If the cloud B is a subset of the cloud A (i.e. the points have the same locations, but they are just a subset) and you know their indices, then you can simply filter the indices.

In the more general case, for which the points in A and B are similar but not the same, you need to get a bit fancier. For each point in B, look for the closest point in A using radius search or kd-search, then remove the identified points from A.

Upvotes: 1

Related Questions