-
Notifications
You must be signed in to change notification settings - Fork 6
/
homo_adm.m
42 lines (36 loc) · 1009 Bytes
/
homo_adm.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
function [Inliers] = homo_adm(data,eps,x0)
kap = 4;
m = size(data.x1,2);
n = 8;
eps = eps*data.T2(1,1);
[A, b, c, d] = genMatrixHomography(data.x1, data.x2);
[A1, b] = genLinearMatrixFromQuasiconvex(A, b, c, d, eps);
%Initialization
if nargin>=3
if (length(x0)==9)
x0 = x0./x0(end);
x0 = x0(1:n);
end
para.x0 = x0;
s = max(reshape(A1*x0-b,kap,m)).';
para.s0 = max(s,0);
else
%--Obtain an initialization by the L1-RD
C = [b; zeros(m,1)];
B = [sparse(n,1); ones(m,1)];
J = kron(speye(m),ones(kap,1));
A = [A1, -J; sparse(m,n), -speye(m)];
K.l = size(A,1);
pars.eps = 1e-7;
pars.maxiter = 1e3;
pars.fid = 0;
[~,Y,~] = sedumi(A,-B,C,K,pars);
para.x0 = Y(1:n);
para.s0 = Y(n+1:end);
end
%-- ADMM algorithm--
para.MAX_ITER = 1e3;
para.TOL = 1e-12;
para.rho = 10;
[~,slack,~] = adm_alg(A1,b,kap,para);
Inliers = find(slack==0);