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
|
Rev | Line | |
---|
[37] | 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 |
|
---|
| 11 | function X = vgg_X_from_xP_lin(u,P,imsize)
|
---|
| 12 |
|
---|
| 13 | if iscell(P)
|
---|
| 14 | P = cat(3,P{:});
|
---|
| 15 | end
|
---|
| 16 | K = size(P,3);
|
---|
| 17 |
|
---|
| 18 | if 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
|
---|
| 26 | end
|
---|
| 27 |
|
---|
| 28 | A = [];
|
---|
| 29 | for k = 1:K
|
---|
| 30 | A = [A; vgg_contreps([u(:,k);1])*P(:,:,k)];
|
---|
| 31 | end
|
---|
| 32 | % A = normx(A')';
|
---|
| 33 | [dummy,dummy,X] = svd(A,0);
|
---|
| 34 | X = X(:,end);
|
---|
| 35 |
|
---|
| 36 | % Get orientation right
|
---|
| 37 | s = reshape(P(3,:,:),[4 K])'*X;
|
---|
| 38 | if any(s<0)
|
---|
| 39 | X = -X;
|
---|
| 40 | if any(s>0)
|
---|
| 41 | % warning('Inconsistent orientation of point match');
|
---|
| 42 | end
|
---|
| 43 | end
|
---|
| 44 |
|
---|
| 45 | return
|
---|
Note: See
TracBrowser
for help on using the repository browser.