source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/zisserman/vgg_multiview/vgg_H_from_x_lin.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1function 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
13if (size(xs1) ~= size(xs2))
14 error ('Input point sets are different sizes!')
15end
16
17if (size(xs1,1) == 2)
18  xs1 = [xs1 ; ones(1,size(xs1,2))];
19  xs2 = [xs2 ; ones(1,size(xs2,2))];
20end
21
22% condition points
23C1 = vgg_conditioner_from_pts(xs1);
24C2 = vgg_conditioner_from_pts(xs2);
25xs1 = vgg_condition_2d(xs1,C1);
26xs2 = vgg_condition_2d(xs2,C2);
27
28D = [];
29ooo  = zeros(1,3);
30for 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   ];
37end
38
39% Extract nullspace
40[u,s,v] = svd(D, 0); s = diag(s);
41 
42nullspace_dimension = sum(s < eps * s(1) * 1e3);
43if nullspace_dimension > 1
44  fprintf('Nullspace is a bit roomy...');
45end
46 
47h = v(:,9);
48
49H = reshape(h,3,3)';
50
51%decondition
52H = inv(C2) * H * C1;
53
54H = H/H(3,3);
Note: See TracBrowser for help on using the repository browser.