source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/zisserman/vgg_multiview/vgg_X_from_xP_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.1 KB
Line 
1%vgg_X_from_xP_lin  Estimation of 3D point from image matches and camera matrices, linear.
2%   X = vgg_X_from_xP_lin(x,P,imsize) computes projective 3D point X (column 4-vector)
3%   from its projections in K images x (3-by-K matrix) and camera matrices P (K-cell
4%   of 3-by-4 matrices). Image sizes imsize (2-by-K matrix) are needed for preconditioning.
5%   By minimizing algebraic distance.
6%
7%   See also vgg_X_from_xP_nonlin.
8
9% werner@robots.ox.ac.uk, 2003
10
11function X = vgg_X_from_xP_lin(u,P,imsize)
12
13if iscell(P)
14  P = cat(3,P{:});
15end
16K = size(P,3);
17
18if nargin>2
19  for k = 1:K
20    H = [2/imsize(1,k) 0 -1
21         0 2/imsize(2,k) -1
22         0 0              1];
23    P(:,:,k) = H*P(:,:,k);
24    u(:,k) = H(1:2,1:2)*u(:,k) + H(1:2,3);
25  end
26end
27
28A = [];
29for k = 1:K
30  A = [A; vgg_contreps([u(:,k);1])*P(:,:,k)];
31end
32% A = normx(A')';
33[dummy,dummy,X] = svd(A,0);
34X = X(:,end);
35
36% Get orientation right
37s = reshape(P(3,:,:),[4 K])'*X;
38if any(s<0)
39  X = -X;
40  if any(s>0)
41%    warning('Inconsistent orientation of point match');
42  end
43end
44
45return
Note: See TracBrowser for help on using the repository browser.