Comparing two point clouds for differences
Ältere Kommentare anzeigen
I am attempting to use two point clouds from the kinect and compare for differences between the two scenes.
The logic is as follows: For each point in point cloud 1, the distance to the nearest neighbor in point cloud 2 is calculated. If the distance is greater then the threshold distance, the indices of the point in point cloud 1 is stored. After completing for loop, the indices are used to select the points in point cloud 1 that were greater than threshold difference.
function [PCDifference] = ComparePC(pc1,pc2)
%Compares two aligned point clouds based on threshold difference
[pc1r,~]=removeInvalidPoints(pc1);
[pc2r,~]=removeInvalidPoints(pc2);
minDist = 0.5;
x=0;
%for each point in pc1 find nearest neighbor distance - if greater then
%threshold distance store point cloud in PCDifference
for i =1:pc1r.Count
point=pc1r.Location(i,:);
[~,dist]=findNearestNeighbors(pc2r,point,1);
if dist > minDist
if true
% code
end
%Store point cloud in indices
x=x+1;
Indices(x,1)=i
end
end
%Plot difference in point clouds
PCDifference=select(pc1r,Indices);
figure
pcshow(PCDifference)
I am receiving errors in PCDifference=select(pc1r,Indices) line. Indices should be a column vector with the indices of points without close neighbor. Is there a better way to approach this? There is no easy way to create point cloud object that changes size every loop. It is best to store the indices and then use the select function afterwards.
Please let me know if you have any ideas.
Thank you, Michael
Antworten (1)
KSSV
am 27 Aug. 2017
0 Stimmen
Doc _ knnsearch_ ...with this you can get the indices of nearest neighbors with ease..
1 Kommentar
Prashik Shende
am 23 Sep. 2020
can use specify how to use knnsearch in code
Kategorien
Mehr zu Kinect For Windows Sensor finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!