source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/MultiCamValidation/CoreFunctions/uP2X.m @ 37

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

Added original make3d

File size: 879 bytes
Line 
1% uP2X ... linear reconstruction of 3D points
2%          from N-perspective views
3%
4% X = uP2X(Umat,Pmat);
5% Umat ... 3*N x n matrix of n homogenous points
6% Ps ...   3 x 4*N matrix of projection matrices
7%
8% X ... 4 x n matrix of homogenous 3D points
9%
10% Algorithm is based on: Hartley and Zisserman, Multiple
11% View Geometry, 2000, pp 297-298
12%
13% $Id: uP2X.m,v 2.0 2003/06/19 12:07:10 svoboda Exp $
14
15function X = uP2X(Umat,Ps);
16
17N = size(Umat,1)/3;
18n =     size(Umat,2);
19
20% reshuffle the Ps matrix
21Pmat = [];
22for i=1:N;
23  Pmat = [Pmat;Ps(:,i*4-3:i*4)];
24end
25
26X = [];
27for i=1:n,      % for all points
28  A = [];       
29  for j=1:N,    % for all cameras
30        % create the data matrix
31        A = [A; Umat(j*3-2,i)*Pmat(j*3,:) - Pmat(j*3-2,:); Umat(j*3-1,i)*Pmat(j*3,:) - Pmat(j*3-1,:)];
32  end
33  [u,s,v] = svd(A);
34  X = [X,v(:,end)];
35end
36% normalize reconstructed points
37X = X./repmat(X(4,:),4,1);
38
39return;
Note: See TracBrowser for help on using the repository browser.