bluechill
bluechill

Reputation: 437

Point cloud registration using pcl

OK, so here is the problem. I followed the link given here for registering a pair of point clouds.

I have a couple of queries:

1) Since the second point cloud is aligned to the frame of the first one, the coordinates of the points in the first point cloud should remain unchanged in the final point cloud, right ?

2) Is there a way to map the target points to the aligned points in the final coordinate. In other words, for example, I have two point clouds pc1 and pc2. pc1 has 3 points A, B, and C, and pc2 has 4 points W, X, Y, and Z. After registration, the final point clouds contains points A, B, C (since they should remain unchanged), and W', X', Y', and Z'. My question is, is there a way to know that W' corresponds to W in the target cloud, X' to X, etc etc. ? Also, is there a way for the other way around? I mean, given W, how to know what it corresponds to (i.e. W') ?

Thanks in advance.

Upvotes: 1

Views: 3578

Answers (1)

datjko
datjko

Reputation: 383

In pcl the registration by itself does changes neither clouds. The result of registration is the transformation from the frame of source cloud to the frame of target cloud.

In your link the registration is done in the pairAlign(). It incrementally runs

points_with_normals_src = reg_result;
reg.align(reg_result);

each time getting as reg_result the transformed points_with_normals_src cloud, and

//accumulate transformation between each Iteration
Ti = reg.getFinalTransformation () * Ti;

accumulating transformation from previous steps.

the transformation (for some reason they want to apply the inverse transformation to target to transform it to the source frame) and the result merge of the aligned clouds happens only after the loop of registrations:

// Transform target back in source frame
pcl::transformPointCloud (*cloud_tgt, *output, targetToSource);
...
//add the source to the transformed target
*output += *cloud_src;

If I understand you right your question is given a point A in cloud_tgt find its image in the merged output cloud? (right?)

If all you need is to find the transformed coordinates of the point A then it's simple:

pcl::PointXYZ transformed_a = targetToSource * a;

If you want to find the index of the transformed A in the output cloud then it's a bit more complicated: though you can simply enumerate all points in output cloud and compare their coordinates with transformed_a this approach will be a noticeable performance issue if you are going to find the correspondence for many points from your target cloud. In this case you'd rather use pcl::search::KdTree (see http://docs.pointclouds.org/trunk/a02948.html)

Upvotes: 2

Related Questions