Register Point Clouds Using Global and Local Registration Techniques
This example shows how to combine global and local registration techniques to accurately align point clouds with significant initial misalignment.
Local registration techniques like pcregistericp
, pcregisterndt
and pcregisterloam
offer greater accuracy compared to global registration techniques like pcregisterfgr
and pcregistercpd
. However, local methods depend on an initial alignment or a known initial transformation. In situations where you register two point clouds with significant misalignment and no known initial transformation, registration might fail to converge to the correct alignment. To illustrate this, the example initially uses the pcregistericp
function, which implements the ICP local registration technique. This approach does not converge to an accurate alignment. Then, it uses the pcregisterfgr
function, which implements the FGR global registration technique resulting in an initial point cloud alignment. Lastly, it combines global and local registration to get an accurate alignment between the point clouds.
Read point cloud data for two point clouds from a Velodyne PCAP file.
veloReader = velodyneFileReader("lidarData_ConstructionRoad.pcap","HDL32E"); ptCloud1 = readFrame(veloReader,1); ptCloud2 = readFrame(veloReader,5);
Transform one of the two point clouds to introduce significant misalignment.
theta = [90 5 -8]; % in degrees
translation = [10 -55 22];
tform = rigidtform3d(theta,translation);
ptCloud2 = pctransform(ptCloud2,tform);
Visualize the misaligned point clouds.
figure pcshowpair(ptCloud1,ptCloud2)
Try to align the point clouds using a local registration technique such as ICP.
tformLocal = pcregistericp(ptCloud2,ptCloud1,Metric="planeToPlane");
alignedPtCloudLocal = pctransform(ptCloud2,tformLocal);
Visualize the alignment that results from local registration.
figure pcshowpair(ptCloud1,alignedPtCloudLocal)
Registration failed to converge to an accurate transformation without initial alignment. Use a global registration technique like FGR for initial alignment of the point clouds.
gridSize = 0.1; tformGlobal = pcregisterfgr(ptCloud2,ptCloud1,gridSize); alignedPtCloudGlobal = pctransform(ptCloud2,tformGlobal);
Visualize the alignment that results from global registration.
figure pcshowpair(ptCloud1,alignedPtCloudGlobal)
To further improve the accuracy of the registration, apply a local registration technique such as ICP to fine-tune the alignment.
tformLocalRefinement = pcregistericp(alignedPtCloudGlobal,ptCloud1,Metric="planeToPlane");
Combine the transformation from the global and local approach to find the transformation that aligns the point clouds.
tformGlobalLocal = rigidtform3d(tformLocalRefinement.A * tformGlobal.A);
Visualize the alignment when combining a global and local registration technique.
alignedPtCloudGlobalLocal = pctransform(ptCloud2,tformGlobalLocal); figure pcshowpair(ptCloud1,alignedPtCloudGlobalLocal)