Line | |
---|
1 | %u2F estimates fundamental matrix using ortogonal LS regression |
---|
2 | % F = u2F(u) estimates F from u using NORMU |
---|
3 | % F = u2F(u,'nonorm') disables normalization |
---|
4 | % see also NORMU, U2FA |
---|
5 | |
---|
6 | |
---|
7 | function F = u2F (u, str) |
---|
8 | |
---|
9 | if (nargin > 1) & strcmp(str, 'nonorm') |
---|
10 | donorm = 0; |
---|
11 | else |
---|
12 | donorm = 1; |
---|
13 | end |
---|
14 | |
---|
15 | ptNum = size(u,2); |
---|
16 | |
---|
17 | if donorm |
---|
18 | A1 = normu(u(1:3,:)); |
---|
19 | A2 = normu(u(4:6,:)); |
---|
20 | |
---|
21 | u1 = A1*u(1:3,:); |
---|
22 | u2 = A2*u(4:6,:); |
---|
23 | end |
---|
24 | |
---|
25 | for i = 1:ptNum |
---|
26 | Z(i,:) = reshape(u1(:,i)*u2(:,i)',1,9); |
---|
27 | end |
---|
28 | |
---|
29 | M = Z'*Z; |
---|
30 | V = seig(M); |
---|
31 | F = reshape(V(:,1),3,3); |
---|
32 | |
---|
33 | [uu,us,uv] = svd(F); |
---|
34 | [y,i] = min (abs(diag(us))); |
---|
35 | us(i,i) = 0; |
---|
36 | F = uu*us*uv'; |
---|
37 | |
---|
38 | if donorm |
---|
39 | F = A1'*F*A2; |
---|
40 | end |
---|
41 | |
---|
42 | F = F /norm(F,2); |
---|
Note: See
TracBrowser
for help on using the repository browser.