-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdemo_LNIFT.m
59 lines (51 loc) · 1.79 KB
/
demo_LNIFT.m
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
clc;clear;close all; warning('off')
addpath dataset\Optical-Optical\
addpath algorithms\LNIFT\;
addpath algorithms\common\
RES=[];
for i=1:200
i
str1=['pair' num2str(i) '_1.jpg'];
str2=['pair' num2str(i) '_2.jpg'];
gtstr =['gt_' num2str(i) '.txt'];
if exist(str1,'file')==0
continue;
end
gt=load(gtstr);
im1 = uint8(imread(str1));
im2 = uint8(imread(str2));
imwrite(im1,'.\algorithms\LNIFT\1.png');
imwrite(im2,'.\algorithms\LNIFT\2.png');
exe='.\algorithms\LNIFT\LNIFT.exe';
cmd = [exe ' ' '.\algorithms\LNIFT\1.png' ' ' '.\algorithms\LNIFT\2.png' ' ' '1' ' ' '.\algorithms\LNIFT\time.txt' ' ' '.\algorithms\LNIFT\matches.txt' ' ' '128' ' ' '4'];
system(cmd);
matches = load('.\algorithms\LNIFT\matches.txt');
time = load('.\algorithms\LNIFT\time.txt');
matchedPoints1 = matches(:,1:2);
matchedPoints2 = matches(:,3:4);
H=[gt;0 0 1];
Y_=H*[matchedPoints1';ones(1,size(matchedPoints1,1))];
Y_(1,:)=Y_(1,:)./Y_(3,:);
Y_(2,:)=Y_(2,:)./Y_(3,:);
E=sqrt(sum((Y_(1:2,:)-matchedPoints2').^2));
inliersIndex=E<3;
cleanedPoints1 = matchedPoints1(inliersIndex, :);
cleanedPoints2 = matchedPoints2(inliersIndex, :);
[cleanedPoints2,IA] = unique(cleanedPoints2,'rows');
cleanedPoints1 = cleanedPoints1(IA,:);
cleanedPoints=[cleanedPoints1 cleanedPoints2];
cleanedPoints = double(cleanedPoints);
Y_=H*[cleanedPoints(:,1:2)';ones(1,size(cleanedPoints,1))];
Y_(1,:)=Y_(1,:)./Y_(3,:);
Y_(2,:)=Y_(2,:)./Y_(3,:);
E=sqrt(sum((Y_(1:2,:)-cleanedPoints(:,3:4)').^2));
if length(E)<10
rmse = 20;
else
rmse = sqrt(sum(E.^2)/size(E,2));
end
length(E)
timeres = double([time rmse size(cleanedPoints,1) size(matches,1)]);
RES = [RES;timeres];
end
save RES_lnift.mat RES