-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatchPointCloundsFast.m
More file actions
59 lines (44 loc) · 1.32 KB
/
matchPointCloundsFast.m
File metadata and controls
59 lines (44 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function [matches1to2,cost]=matchPointCloundsFast(pos_1,pos2,constraints)
%match two roughly aligned point clouds using distance
costmatrix=distance(pos_1',pos2');
if exist('constraints','var')
costmatrix=max(costmatrix,constraints);
end
%costmatrix(costmatrix>40)=inf;
%extend cost matrix with col for no link costs
%{
nolink=ones(length(pos_1),length(pos_1)).*inf;
for i=1:length(nolink)
nolink(i,i)=40;
end
costmatrix=[costmatrix,nolink];
%costmatrix=[costmatrix,ones(length(pos_1),length(pos_1)).*35];
%}
%tic
%[matches1to2,cost]=munkres(costmatrix);%matching
%toc
%slower even dammit
%tic
%[matches1to2j,costj]=linear_sum_assignment(costmatrix);
%toc
%note this implementation seems to be order of magnitude faster than
%munkres though puts output in weird format that I think this fixes
[matches1to2j,costj,u,v]=lapjv(costmatrix);%matching
if(size(costmatrix,1)>size(costmatrix,2))
matches1to2jc=zeros(1,size(costmatrix,1));
for i=1:length(matches1to2j)
if(matches1to2j(i)~=0)
matches1to2jc(matches1to2j(i))=i;
end
end
matches1to2=matches1to2jc;
else
matches1to2=matches1to2j;
end
%toc
cost=costj;
%}
% matches1to2(matches1to2>length(pos2))=0;% matches that are no link
% options are set to zero
%}
end