SIMULTANEOUS ALIGNMENT OF SIX POINT CLOUDS
In this example six point clouds are aligned simultaneosly by the ICP algorithm. For this the globalICP class is used.
Contents
Note: You can extract the code from this html file with the matlab function grabcode
Where to get help
Before starting, a short hint on how to access the helpscreen of the methods (=functions) used within this tutorial:
% Help for the constuctor method (for object creation) help globalICP.globalICP % Constructor method for globalICP class. % Help for regular methods help globalICP.addPC % Add a point cloud to globalICP object. help globalICP.plot % Plot all added point clouds. help globalICP.runICP % Run ICP algorithm. help globalICP.exportPC % Export a point cloud.
Import point clouds and run ICP algorithm
clc; clear; close; % clear everything % Contruct an object of class globalICP (=initialization) icp = globalICP; % Add point clouds to object from plain text files % (Added point clouds are saved as mat files, e.g. LionScan1Approx.mat) icp.addPC('LionScan1Approx.xyz'); icp.addPC('LionScan2Approx.xyz'); icp.addPC('LionScan3Approx.xyz'); icp.addPC('LionScan4Approx.xyz'); icp.addPC('LionScan5Approx.xyz'); icp.addPC('LionScan6Approx.xyz'); % Plot all point clouds BEFORE ICP (each in a different random color) icp.plot('Color', 'by PC'); title('BEFORE ICP', 'Color', 'w'); view(0,0); set(gcf, 'Name', 'BEFORE ICP'); % Run ICP! icp.runICP('UniformSamplingDistance', 2, ... 'PlaneSearchRadius', 2); % Plot all point clouds AFTER ICP icp.plot('Color', 'by PC'); title('AFTER ICP', 'Color', 'w'); view(0,0); set(gcf, 'Name', 'AFTER ICP');
Convergence animation
See here how distances between the point clouds are minimized during the ICP process. Since the point-to-plane distance is used in the ICP algorithm, one can see that already after the first iteration the orientation of the point clouds is quiet fine. Further iteration minimize small remaining differences between the point clouds. After 5 iteration the final orientation is reached.
Export of aligned point clouds as xyz files
icp.exportPC(1, 'LionScan1Fine.xyz'); % export first added point cloud icp.exportPC(2, 'LionScan2Fine.xyz'); % export second added point cloud icp.exportPC(3, 'LionScan3Fine.xyz'); % ... icp.exportPC(4, 'LionScan4Fine.xyz'); icp.exportPC(5, 'LionScan5Fine.xyz'); icp.exportPC(6, 'LionScan6Fine.xyz'); % For further export options call 'help globalICP.exportPC'
Result analysis (statistics)
After each iteration a short summary of the most important statistics is reported on the workspace. For instance, after the fifth iteration the results are:
| S : GLOBALICP > RUNICP > ICP ITERATION 5 OF 5 > RESULTS | T : ------------------------------------------------------------------------------- | T : GENERAL STATISTICS: | T : iteration corresp. std(dp) mean(dp) norm(dx) | T : 1 782 0.50211 0.00551 7.43741 | T : 2 1151 0.15302 -0.00424 1.01275 | T : 3 1293 0.11664 -0.00521 0.19642 | T : 4 1277 0.11217 -0.00274 0.09391 | T : new: 5 1279 0.10657 -0.00139 0.12152 | T : where dp = vector of all (signed) point-to-plane distances | T : dx = vector of parameter increments | T : ------------------------------------------------------------------------------- | T : POINT CLOUD DEPENDANT STATISTICS: | T : point_cloud corresp. std(dp) mean(dp) file | T : [1] 309 0.08279 -0.00414 LionScan1Approx | T : [2] 688 0.10915 0.00036 LionScan2Approx | T : [3] 496 0.11629 -0.00473 LionScan3Approx | T : [4] 317 0.07783 0.00170 LionScan4Approx | T : [5] 651 0.12259 0.00037 LionScan5Approx | T : [6] 135 0.09622 0.01251 LionScan6Approx | T : where dp = vector of all (signed) point-to-plane distances associated to a single point cloud | T : -------------------------------------------------------------------------------