source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/zisserman/vgg_multiview/vgg_KR_from_P.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: 853 bytes
Line 
1%VGG_KR_FROM_P Extract K, R from camera matrix.
2%
3%    [K,R,t] = VGG_KR_FROM_P(P [,noscale]) finds K, R, t such that P = K*R*[eye(3) -t].
4%    It is det(R)==1.
5%    K is scaled so that K(3,3)==1 and K(1,1)>0. Optional parameter noscale prevents this.
6%
7%    Works also generally for any P of size N-by-(N+1).
8%    Works also for P of size N-by-N, then t is not computed.
9
10
11% Author: Andrew Fitzgibbon <awf@robots.ox.ac.uk>
12% Modified by werner.
13% Date: 15 May 98
14
15
16function [K, R, t] = vgg_KR_from_P(P, noscale)
17
18N = size(P,1);
19H = P(:,1:N);
20
21[K,R] = vgg_rq(H);
22 
23if nargin < 2
24  K = K / K(N,N);
25  if K(1,1) < 0
26    D = diag([-1 -1 ones(1,N-2)]);
27    K = K * D;
28    R = D * R;
29   
30  %  test = K*R;
31  %  vgg_assert0(test/test(1,1) - H/H(1,1), 1e-07)
32  end
33end
34
35if nargout > 2
36  t = -P(:,1:N)\P(:,end);
37end
38
39return
Note: See TracBrowser for help on using the repository browser.