www.gusucode.com > vision 源码程序 matlab案例代码 > vision/AlignTwoPointCloudsExample.m
%% Align Two Point Clouds % Load point cloud data. % Copyright 2015 The MathWorks, Inc. ptCloud = pcread('teapot.ply'); figure pcshow(ptCloud); title('Teapot'); %% % Create a transform object with 30 degree rotation along _z_ -axis and translation [5,5,10]. A = [cos(pi/6) sin(pi/6) 0 0; ... -sin(pi/6) cos(pi/6) 0 0; ... 0 0 1 0; ... 5 5 10 1]; tform1 = affine3d(A); %% % Transform the point cloud. ptCloudTformed = pctransform(ptCloud,tform1); figure pcshow(ptCloudTformed); title('Transformed Teapot'); %% % Apply the rigid registration. tform = pcregrigid(ptCloudTformed,ptCloud,'Extrapolate',true); %% % Compare the result with the true transformation. disp(tform1.T); tform2 = invert(tform); disp(tform2.T);