Last change
on this file since 177 was
37,
checked in by (none), 15 years ago
|
Added original make3d
|
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Line | |
---|
1 | function H = vgg_H_from_x_lin(xs1,xs2)
|
---|
2 | % H = vgg_H_from_x_lin(xs1,xs2)
|
---|
3 | %
|
---|
4 | % Compute H using linear method (see Hartley & Zisserman Alg 3.2 page 92 in
|
---|
5 | % 1st edition, Alg 4.2 page 109 in 2nd edition).
|
---|
6 | % Point preconditioning is inside the function.
|
---|
7 | %
|
---|
8 | % The format of the xs [p1 p2 p3 ... pn], where each p is a 2 or 3
|
---|
9 | % element column vector.
|
---|
10 |
|
---|
11 | [r,c] = size(xs1);
|
---|
12 |
|
---|
13 | if (size(xs1) ~= size(xs2))
|
---|
14 | error ('Input point sets are different sizes!')
|
---|
15 | end
|
---|
16 |
|
---|
17 | if (size(xs1,1) == 2)
|
---|
18 | xs1 = [xs1 ; ones(1,size(xs1,2))];
|
---|
19 | xs2 = [xs2 ; ones(1,size(xs2,2))];
|
---|
20 | end
|
---|
21 |
|
---|
22 | % condition points
|
---|
23 | C1 = vgg_conditioner_from_pts(xs1);
|
---|
24 | C2 = vgg_conditioner_from_pts(xs2);
|
---|
25 | xs1 = vgg_condition_2d(xs1,C1);
|
---|
26 | xs2 = vgg_condition_2d(xs2,C2);
|
---|
27 |
|
---|
28 | D = [];
|
---|
29 | ooo = zeros(1,3);
|
---|
30 | for k=1:c
|
---|
31 | p1 = xs1(:,k);
|
---|
32 | p2 = xs2(:,k);
|
---|
33 | D = [ D;
|
---|
34 | p1'*p2(3) ooo -p1'*p2(1)
|
---|
35 | ooo p1'*p2(3) -p1'*p2(2)
|
---|
36 | ];
|
---|
37 | end
|
---|
38 |
|
---|
39 | % Extract nullspace
|
---|
40 | [u,s,v] = svd(D, 0); s = diag(s);
|
---|
41 |
|
---|
42 | nullspace_dimension = sum(s < eps * s(1) * 1e3);
|
---|
43 | if nullspace_dimension > 1
|
---|
44 | fprintf('Nullspace is a bit roomy...');
|
---|
45 | end
|
---|
46 |
|
---|
47 | h = v(:,9);
|
---|
48 |
|
---|
49 | H = reshape(h,3,3)';
|
---|
50 |
|
---|
51 | %decondition
|
---|
52 | H = inv(C2) * H * C1;
|
---|
53 |
|
---|
54 | H = H/H(3,3);
|
---|
Note: See
TracBrowser
for help on using the repository browser.