Write a point cloud after performing non-ridge registration (pcregistercpd + pctransform) in matlab

4 views (last 30 days)
I have performed non-ridge registration for two point clouds in matlab. And then I want to merge the two point cloud and write it as a new point cloud. I have tried pcmerge, but pcmerge function only merges point clouds using a box grid filter in the region of overlap.
  1. I want both overlap and not overlap areas
  2. although the overlapping two clouds using pcshowpair function looks promising, the actual print-out clouds are only contain few points each. How can I increase the density of each cloud before merge. Thanks,
% show two clouds points
cleanAdown = pcdownsample(ptCloud1,'gridAverage',0.03);
cleanBdown = pcdownsample(ptCloud2,'gridAverage',0.03);
[tform,rmse] = pcregistercpd(cleanAdown,cleanBdown,'Transform',"Nonrigid");
% alignment
movingReg = pctransform(cleanAdown,tform);
figure;
pcshowpair(movingReg,cleanBdown,'MarkerSize',50);
legend({'Moving point cloud','Fixed point cloud'},'TextColor','w');

Answers (1)

Shivam Singh
Shivam Singh on 4 Apr 2022
Hello Yinghsuan,
  • It is my understanding that you want to merge both the overlapping and non-overlapping areas of the two-point clouds. For doing so, you may concatenate the two point clouds using “pccat” function and then downsample using “pcdownsample” function.
% Merge two point clouds,i.e., ptCloud1 & ptCloud2
% Merge both overlapping and non-overlapping areas
ptCloudConcatenated = pccat([ptCloud1, ptCloud2]);
mergeSize =0.01;
ptCloudMerged = pcdownsample(ptCloudConcatenated, "gridAverage", mergeSize);
  • I also understand that you want to increase the density of each cloud before merge. For doing so, you can use the original point clouds, which are dense. You may use rigid transformation in such case. You may refer the following example for reference:
% Load the livingRoom dataset
dataFile = fullfile(toolboxdir('vision'), 'visiondata', 'livingRoom.mat');
load(dataFile)
% Extract two consecutive point clouds
ptCloud1 = livingRoomData{1};
ptCloud2 = livingRoomData{2};
% show two clouds points
cleanAdown = pcdownsample(ptCloud1,'gridAverage',0.03);
cleanBdown = pcdownsample(ptCloud2,'gridAverage',0.03);
% Estimating Rigid transformation
[tform,~, rmse] = pcregistercpd(cleanAdown,cleanBdown,'Transform',"Rigid");
% Alignment of original moving point cloud, i.e. ptCloud1
movingReg = pctransform(ptCloud1,tform);
figure;
pcshowpair(movingReg,ptCloud2,'MarkerSize',50);
legend({'Moving point cloud','Fixed point cloud'},'TextColor','w');

Products

Community Treasure Hunt

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

Start Hunting!