Merging Point Clouds to get a 3-D model

3 visualizaciones (últimos 30 días)
WANG Zhenyu
WANG Zhenyu el 11 de Dic. de 2015
Editada: WANG Zhenyu el 11 de Dic. de 2015
Hi All, I want to merge multiple point cloud files by using 3-D Point Cloud Processing in MATLAB R2015b. There are six PLY files as input. According to the example code, I process the six point clouds, but the error is very high. It cannot get a complete 3-D model. Anyone can help me?
Thanks in advance for any help.
This code:
%%Register Two Point Clouds
% Extract two consecutive point clouds and use the first point cloud as
% reference.
ptCloudRef = pcread('man1-points.ply');
ptCloudCurrent = pcread('man2-points.ply');
% pcshowpair(ptCloudRef,ptCloudCurrent);
% clear data
ptCloudRef = pcdenoise(ptCloudRef);
ptCloudCurrent = pcdenoise(ptCloudCurrent);
The quality of registration depends on data noise and initial settings of the ICP algorithm. You can apply preprocessing steps to filter the noise or set initial property values appropriate for your data. Here, preprocess the data by downsampling with a box grid filter and set the size of grid filter to be 10cm. The grid filter divides the point cloud space into cubes. Points within each cube are combined into a single output point by averaging their X,Y,Z coordinates.
gridSize = 4;
fixed = pcdownsample(ptCloudRef, 'gridAverage', gridSize);
moving = pcdownsample(ptCloudCurrent, 'gridAverage', gridSize);
% fixed = pcdownsample(ptCloudRef, 'random', 0.8);
% moving = pcdownsample(ptCloudCurrent, 'random', 0.8);
% Note that the downsampling step does not only speed up the registration,
% but can also improve the accuracy.
To align the two point clouds, we use the ICP algorithm to estimate the 3-D rigid transformation on the downsampled data. We use the first point cloud as the reference and then apply the estimated transformation to the original second point cloud. We need to merge the scene point cloud with the aligned point cloud to process the overlapped points.
Begin by finding the rigid transformation for aligning the second point cloud with the first point cloud. Use it to transform the second point cloud to the reference coordinate system defined by the first point cloud.
%tform = pcregrigid(moving, fixed,'InlierRatio',0.32, 'Verbose',true,'Extrapolate', true);
tform = pcregrigid(moving, fixed,'InlierRatio',0.39, 'Verbose',true, 'Extrapolate', true);
ptCloudAligned = pctransform(ptCloudCurrent,tform);
We can now create the world scene with the registered data. The overlapped region is filtered using a 1.5cm box grid filter. Increase the merge size to reduce the storage requirement of the resulting scene point cloud, and decrease the merge size to increase the scene resolution.
mergeSize = 1;
ptCloudScene = pcmerge(ptCloudRef, ptCloudAligned, mergeSize);
% Visualize the input images.
figure
subplot(2,2,1)
pcshow(ptCloudRef, 'VerticalAxis','Y', 'VerticalAxisDir', 'Down')
title('First input')
xlabel('X')
ylabel('Y')
zlabel('Z')
drawnow
subplot(2,2,3)
pcshow(ptCloudCurrent, 'VerticalAxis','Y', 'VerticalAxisDir', 'Down')
title('Second input')
xlabel('X')
ylabel('Y')
zlabel('Z')
drawnow
% Visualize the world scene.
subplot(2,2,[2,4])
pcshow(ptCloudScene, 'VerticalAxis','Y', 'VerticalAxisDir', 'Down')
title('Initial world scene')
xlabel('X')
ylabel('Y')
zlabel('Z')
drawnow

Respuestas (0)

Categorías

Más información sobre Point Cloud Processing en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by