source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/zisserman/vgg_multiview/vgg_line3d_from_lP_lin.m

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

Added original make3d

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1% vgg_line3d_linear  Linear estimation of 3d line from image lines and camera matrices.
2%
3% SYNOPSIS
4% L = vgg_line3d_from_lP_lin(s,P [,imsize]), where
5%
6% s ... cell(K) of double(3,3), inv. covariance matrices of the K image line segments:-
7%   - If the segments are estimated from edges, it is s(:,k) = x*x',
8%     where x (3-by-N) are homog. coordinates of the edgels with last components 1.
9%   - If only end points are available, s(:,k) = d*x*y' where x, y (column 2-vectors)
10%     are the segment's end points and d its length.
11%
12% P ... cell(K) of double(3,4), camera matrices
13%
14% imsize ... double(2,K), image sizes (for preconditioning).
15%   Omit if s and P are already preconditioned.
16%
17% L ... double(4,2), 3d straight line; columns of L are two homogeneous
18%   points spanning the line.
19
20function L = vgg_line3d_from_lP_lin(s,P,imsize)
21
22if nargin < 3, imsize = []; end
23
24K = length(P); % number of images
25
26% l := straight lines in homog. coords
27for k = 1:K
28  l(k,:) = vgg_fit_hplane_to_x(s{k});
29end
30
31if ~isempty(imsize) & K>2 % Preconditioning; for 2 views is not needed
32  for k = 1:K
33    [H,invH] = vgg_conditioner_from_image(imsize(:,k));
34    P{k} = H*P{k};
35    l(k,:) = l(k,:)*invH;
36  end
37  l = norml(l);
38end
39
40M = [];
41for k = 1:K
42  M = [M; l(k,:)*P{k}];
43end
44
45[u,s,v] = svd(normx(M')',0);
46L = v(:,end-1:end);
47
48return
49
50
51function x = normx(x)
52x = x./(ones(size(x,1),1)*sqrt(sum(x.*x)));
53
54function l = norml(l)
55% l = norml(l)  Multiplies hyperplane l by scalar so that for each n, norm(l(1:end-1,n))==1.
56l = l./(sqrt(sum(l(:,1:end-1).^2,2))*ones(1,size(l,2)));
Note: See TracBrowser for help on using the repository browser.