Alignment and Registration
This section deals with alignment and registration of 3D entities (clouds or meshes).
- 1 General considerations
- 2 Alignment
- 3 Automatic registration
Did you say mesh?
(skip this part if you don't work with triangular meshes)
As often with CloudCompare, meshes will generally be considered as clouds, either by considering their vertices only or by sampling points on the mesh surface. For instance you can call the Fine registration tool (ICP) directly on a mesh. But behind the scenes CC will automatically sample points on this mesh in order to use it for ICP registration.
There's only one notable exception: the 'Point pair based' alignment tool can now be used directly on meshes (when the user clicks on a triangle, CloudCompare will determine the actual intersection point on the triangle surface).
So instead of letting CloudCompare chose, you can of course do this conversion yourself:
- instead of selecting the mesh entity, you can simply select its 'vertices' (a point cloud named 'vertices' - generally a child of the mesh entity in the DB tree). In this case you can 'hide' the mesh entity (uncheck the 'visible' checkbox in the mesh properties) and instead display its vertices (check the equivalent 'visible' checkbox in the 'vertices' cloud properties). As mesh vertices are generally quite sparse, you can also increase the points size (the -/+ interactors that appear when you hover the mouse in the top-left corner of a 3D view).
- you can alternatively sample points on the mesh (this way you'll have more control on this process) and use the sampled cloud in place of the mesh. In the particular case of registration, if you want to apply the resulting transformation to the original mesh afterwards, refer to the next section.
Rigid transformation matrices
(skip this part if you really hate maths - otherwise it might give you some interesting hints ;)
Almost all methods presented below are in fact various ways to produce a rigid transformation (matrix) to make an entity move relatively to another one (see Apply Transformation). Whatever the registration tool you use, CloudCompare will always issue the resulting transformation matrix in the console. This allows the user to apply it - or its inverse - to any other entity.
To do so:
- first copy the matrix from the Console (typically with the shortcut CTRL+C on Windows)
- then select the entity you wish to move
- call the 'Edit > Apply Transformation' tool
- paste the 4x4 matrix in the first tab. You can use the dedicated shortcut (e.g. CTRL+V on Windows) or the 'clipboard' button (CloudCompare should automatically get rid of the block prefix - [time between brackets])
- you can even apply the inverse transformation by checking the corresponding checkbox (e.g. to go back to the previous position of the entity)
This trick can be very useful to perform registration on a small portion of a cloud (which you would have segmented beforehand - typically with the ' scissors' tool). Then you can apply the same transformation to the whole cloud afterwards or to another entity (mesh, etc.). See the ' Alternative method for registering partially overlapping clouds' section.
CloudCompare offers various ways to roughly or finely align point clouds or meshes.
Match bounding-box centers
The easiest one is the bounding-box centers matching method. Simply select two (or more) entities, then call 'Tools > Register > Match bounding-box centers' (immediate effect, no dialog). It will center all the selected entities on their respective center of gravity.
It's clearly a very simple approach (it can only translate entities, and not rotate them). However it can save you a few clicks.
It is possible to interactively displace with the mouse one or several entities (relatively to other entities). See the Rotate/Translate tool .
Picking (equivalent) point pairs
Another powerful yet simple tool to align two entities is the Align (point pairs picking) tool . It lets the user pick several pairs of equivalent points in each cloud in order to register them. While the process is manual it can be relatively fast and quite accurate (especially if registration spheres are present in both clouds as this tool is now able to detect their center automatically).
Auto-align (I'm lucky)
A research tool is accessible via the 'Tools > Sand box (research) > Auto align clouds' menu entry. It's an implementation of the Four Points Congruent Sets (4PCS) registration algorithm (by Dror Aiger, Niloy J. Mitra and Daniel Cohen-Or).
Sadly it's still very buggy and not well documented so you're likely to lose more time by using this method (even if it's 'automatic') than directly using one of the above. Maybe in the future if someone dares to dig in the code and fix it...
Fine registration with ICP
Alternative method for registering partially overlapping clouds
Here is an old way of registering two partially overlapping clouds (i.e. prior to version 2.6.1 and its Final overlap parameter).
- First, roughly register the two clouds (with the 'Rotate/Translate' tool for instance).
Note: if you don't already know which cloud will be the data cloud (the one that will move) and which one will be the model cloud (the one that won't move) then you should select the densest one as model (reference)
Creating a subset of the data cloud
- clone the data cloud and hide the original one
- select the new version of the data cloud and use the manual segmentation tool to keep only the points clearly overlapping with the model cloud
Register the 'data' cloud (subset) with the model cloud
- apply the Fine registration (ICP) algorithm to the data cloud subset and the 'model' cloud
- once done, CloudCompare will output the resulting transformation matrix in the Console
- copy this transformation (CTRL+C on Windows)
Apply the rigid transformation to the original data cloud
- make the original data cloud visible again and select it
- launch the ' Edit > Apply Transformation' tool
- paste the transformation (CTRL+V on Windows) in the first tab
- click on the 'OK' button