ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Delete duplicate point cloud of the same part.

asked 2014-08-20 17:36:14 -0500

faty gravatar image

Hi; I would to create a 3D map with Kinect, using PCL, I have two point cloud aligned and concatenated but their concatenation contains duplicate point cloud of the same part. How can I delete this duplication without losing data. I really appreciate any kind of help ! Thanks.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2014-08-21 09:17:46 -0500

paulbovbel gravatar image

updated 2014-08-21 09:18:06 -0500

How aligned, and what are your constraints on the output? That really makes a big difference.

If you're willing to lose some representational accuracy, you can run the concatenated cloud through a VoxelGrid filter, which downsamples the cloud and leaves only one point for every x^3 size cube (leaf). This is essentially what the octomap will do, except that the output remains a point cloud.

If every point is perfectly aligned with every other, which is extremely unlikely, you can insert all the points into a Map, using the x,y,z tuple as the key, and remove any points that double up on one key.

edit flag offensive delete link more
3

answered 2014-08-20 18:16:16 -0500

Have you looked at octomap? It can almost certainly do what you want.

edit flag offensive delete link more

Comments

thanks for your reply, but I'is not what I' am loking for. ^^

faty gravatar image faty  ( 2014-08-21 05:58:17 -0500 )edit
0

answered 2019-07-12 02:37:41 -0500

Solrac3589 gravatar image

updated 2019-07-12 03:14:16 -0500

Hello, I amb like 5 years late, but maybe somebody search that and maybe wants a response.

I reached this place searching exactly the same, and even not finding that solution i realized two ways to solve it.

First of all, I am going to define that the reason why a point is duplicated in two pointclouds which you want to concatenate, probably (and at least is the only possibility I realise) it is because they come from the same pointcloud, whic chave been filtered in different ways (in my case, for example, i did a difference of normals filtering and a difference of grayscale filtering).

First approach: Add two or more conditions into the removal: During the filtering, there is the options of pcl:ConditionAnd and pcl::ConditionOr which can concatenate more than one conditions (with addComparison function or addCondition). This way you should be able to directly generate the filtered/concatenated pointcloud.

A main drawback? lets imagine my case in which each filtering is done using a dirrefent kind of pointcloud (pointXYZI with intensity and pcl::PointNormal with curvate) how you merge both pointclouds into one condition? here appears my second approach

Second approach

Just do as you desired originally (so, we create two independent filtered clouds). Remember in this case to set the setKeepOrganized insideconditionalremoval to false, to store the original index (the removed ones will become NaN).

Once you did that, the easies tolution is to convert both pointclouds into the same kind, something like:

pcl::copyPointCloud<pcl::PointXYZI, pcl::PointXYZ>( cloud_with_i, cloud_without_i);

and then apply the following code (dith cloud1 and cloud2 the clouds to concatenate):

pcl::PointCloud<pcl::PointXYZ> cloud_concatenated;

cloud_concatenated = cloud1; bool condition1=false; bool condition2=false;
for (int i = 0; i < cloud_concatenated.points.size(); i++) {
  condition1 = (isnan(cloud_concatenated.points[i].x)) && (isnan(cloud_concatenated.points[i].y)) (isnan(cloud_concatenated.points[i].z));
  condition2 = (!isnan(cloud2.points[i].x)) && (!isnan(cloud2.points[i].y)) (!isnan(cloud2.points[i].z));
  if (condition1 && condition2) {
    cloud_concatenated.points[i].x  = cloud2.points[i].x;
    cloud_concatenated.points[i].y  = cloud2.points[i].y;
    cloud_concatenated.points[i].z  = cloud2.points[i].z;
  }
}

Finally if you want to remove the Nan extra valures, just apply pcl::removeNaNFromPointCloud.

I could not test the code. so if there is any issue, please help to imporve the response :)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-08-20 17:36:14 -0500

Seen: 3,135 times

Last updated: Jul 12 '19