Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Computing the 3D Transformation between Two Sets of Points

Using a Microsoft Kinect, I am collecting depth data about an object. From these data, I create a "cloud" of points (point cloud), which, when plotted, allow me to view the object that I scanned using the Kinect.

However, I would like to be able to collect multiple point clouds from different "views" and align them. More specifically, I would like to use an algorithm such as Iterative Closest Point (ICP) to do so, transforming each point in my point cloud by calculating the rotation and translation between each cloud that I collect and the previously-collected cloud.

However, while I understand the process behind ICP, I do not understand how I would implement it in 3D. Perhaps it is my lack of mathematical experience or my lack of experience with frameworks such as OpenCV, but I cannot find a solution. I would like to avoid libraries such as the Point Cloud Library which does this sort of thing for me, since I would like to do it myself.

Any and all suggestions are appreciated (if there is a solution that involves OpenCV/python that I can work on, that would be even better!)

like image 205
nmagerko Avatar asked Dec 11 '13 19:12

nmagerko


People also ask

What is 3D coordinate transformation?

A three-dimensional (3D) conformal coordinate transformation, combining axes rotations, scale change and origin shifts is a practical mathematical model of the relationships between different 3D coordinate systems.

What is 3D transformation in CAD?

3-D Transformation is the process of manipulating the view of a three-D object with respect to its original position by modifying its physical attributes through various methods of transformation like Translation, Scaling, Rotation, Shear, etc.

How many corresponding pairs of 2D points do you need to solve for a perspective transform?

Since the Homography matrix has 8 degrees of freedom, we need at least four pairs of corresponding points to solve for the values of the Homography matrix. We can then combine the relationships between all four points like below. Equation 7: Relationship between n pairs of matching points. Image by Author.


1 Answers

I am currently struggling with ICP myself. Here is what I have gathered so far:

ICP consists of three steps:

  • Given two point clouds A and B, find pairs of points between A and B that probably represent the same point in space. Often this is done simply by matching each point with its closest neighbor in the other cloud, but you can use additional features such as color, texture or surface normal to improve the matching. Optionally you can then discard the worst matches.
  • Given this list of correspondence pairs, find the optimal transformation from A to B
  • Apply this transformation to all points in A
  • repeat these three steps until you converge on an acceptable solution.

Step one is easy, although there are lots of ways to optimize its speed, since this is the major performance bottleneck of ICP; and to improve the accuracy, since this is the main source of errors. OpenCV can help you there with the FLANN library.

I assume your troubles are with step two, finding the best transformation given a list of correspondences.

One common approach works with Singular Value Decomposition (SVD). Here is a rough sketch of the algorithm. Searching for ICP & SVD will give a lot of further references.

  • Take the list of corresponding points A1..An and B1..Bn from step 1
  • calculate the centroid Ca of all points in A and the centroid Cb of all points in B
  • Calculate the 3x3 covariance matrix M
    M = (A1 - Ca)* (B1 - Cb)T + ... + (An - Ca)* (Bn - Cb)T
  • Use SVD to calculate the 3x3 Matrices U and V for M
    (OpenCV has a function to perform SVD)
  • Calculate R = U * VT.
    This is your desired optimal rotation matrix.
  • Calculate the optimal translation as Cb - R*Ca
  • The optimal transformation is the combination of R and this translation

Please note that I have not yet implemented this algorithm myself, so I am only paraphrasing what I read.

like image 141
HugoRune Avatar answered Sep 21 '22 09:09

HugoRune