Here I briefly explained how the RHT works, with reference to a very simple case (finding the directions of rows and columns of a grid). Now I’ll spend some words on a more complex application.
When scanning the surface of an object with an optical scanner, be it based on laser or binocular photogrammetry, some portions of the surface may not be acquired, due to occlusions (they are hidden by other portions of the surface and therefore not reached by the laser ray or not seen by both cameras) or simply because the object is larger than the field of the scanning device.
The solution is to move the object and/or the scanner, so that the hidden parts become visible, and to repeat the acquisition as many times as needed. Then the rototranslations between the different poses must be determined in order to merge the acquisitions in a single point cloud.
To determine the rototranslations, one possibility is to have the scanner carried by something which keeps track of its position and orientation, eg a robotic arm having position encoders at its joints.
Another possibility is to match at least three (the more the better) non-aligned points across each couple of poses. Three couples of non-aligned points determine a rototranslation. The points can be intrinsic features of the object being scanned, or easily recognizable markers purposedly sticked onto the object.
In this second case we have a number of acquisitions, each with a list of 3D reference points. We know that the reference points of, say, acquisition A, as a whole, are in correspondence with those of, say, acquisition B, because they refer to the same 3D entities, but we don’t know in which order the correspondences are. Also, the elements in the A list need not be precisely as many as those in the B list – maybe one or more markers were acquired in A and missed in B, or the reverse. Even worse, maybe some markers were missed both in A and in B, but not the same markers – so that the two lists contain some points which do correspond, even if in unknown order, but also some which do not correspond at all.
Not very simple, isn’t it? Well, RHT can help.
In my previous post, RHT was used to extract shapes (straight lines, circumferences, …) from minimal subsets of samples (couples or triples of points in an image). Here, the concepts of shape and sample must be extended: the shape is the rototranslation, and the minimal subsets are triples of couples of 3D points.
While two non coincident points always define a straight line and three non collinear points always define a circumference, it is not true that any three couples of points always define a rototranslation. The rototranslation is a rigid transformation. Therefore, if the three of couples of points are connected by the rototranslation , so that , , , it must be true that , , .
This fact can be useful to discard a priori minimal subsets not respecting this constraint, avoiding further computation on them. Of course, one must remember that the equality sign is a mathematical abstraction never showing up in the real world. Due to unavoidable acquisition and reconstruction errors, the lengths of corresponding segments will never be precisely equal, so the check must be done with a small tolerance.
As said in my previous post on this subject, the RHT algorithm needs to compare two shapes to determine how much they differ. How can we measure the dissimilarity between two rototranslations?
I found satisfactory to define the dissimilarity as the root mean square difference of the lengths of the edges of a simplex. Let
where is a characteristic length of the problem, eg the linear size of the field of measure. Then I define the dissimilarity between two rototranslations and as
is non-negative, it is null for identical rototranslations and, thanks to the characteristic length , it keeps into account both the effects of the translation and of the rotation putting them on a common ground.
That said, the RHT algorithm for rototranslations follows the same steps as described in my previous post. Here is the pseudocode:
- Initialize an empty list of rototranslations.
- Repeat 3..10 for a maximum number of times:
- Randomly choose three distinct points from the first acquisition.
- Randomly choose three distinct points from the second acquisition.
- If the rigidity constraint is violated, restart from 3.
- Compute the rototranslation defined by the three couples of points.
- If the list of rototranslations is empty, add the new rototranslation to the list, keeping track of the three couples of points used to compute it.
- Otherwise if the list of rototranslations is not empty, compute the dissimilarity of the new rototranslation with respect to all those in the list.
- If the lowest dissimilarity found is under a specified threshold, merge the two rototranslations by merging their associated samples (couples of points) and recomputing the rototranslation. If the merged rototranslation has enough samples, exit the iterations.
- Otherwise if the lowest dissimilarity found is over a specified threshold, add the new rototranslation to the list.
Several algorithms are available to compute the rototranslation given three or more couples of points; see eg Lorusso, Eggert and Fisher, A Comparison of Four Algorithms for Estimating 3-D Rigid Transformations.
The choice of the random number generator used to extract the minimal subsets is critical. It must be a good one, with an as long as possible cycle. I used the Mersenne generator by Agner Fog. Also, be aware that two independent generators (with different seeds) must be used to extract the samples from the first and from the second acquisition.
The algorithm, as described, needs three parameters:
- maximum number of iterations;
- dissimilarity threshold to decide if the new rototranslation has to be merged with an existing one or must be added to the list;
- minimum number of samples to accept a rototranslation as a valid result and exit the algorithm.
It could also be a good idea to give up the search after a certain number of iteration without finding a new minimal subset different from those already seen.
I haven’t made thorough testing, but I dare say that RHT is competitive with RANSAC for finding rototranslations.
Here you find a short movie (5 min) showing the acquisition and registration of point clouds based on marker matching with the RHT for rototranslations algorithm.