source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/MultiCamSelfCal/MartinecPajdla/fill_mm/depth_estimation.m @ 37

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

Added original make3d

File size: 933 bytes
Line 
1%depths_estimation Determine scale factors (proj. depths) of PRMM.
2
3function [lambda, Ilamb] = depth_estimation(M,F,ep,rows,central)
4
5[m n] = size(M); m = m/3;
6
7if central
8  j  = central;
9  ps = 1:n;
10  Ilamb(j,:) = ~isnan(M(3*j,:));
11else
12  j = 1;
13  b = subseq_longest(~isnan(M(1:3:end,:)));
14  for p = 1:n
15    Ilamb(b(p),p) = ~isnan(M(3*b(p),p)); % =1 is sufficient if b(p) is correct
16  end
17end
18
19lambda = ones(m,n);
20
21for i = setdiff(1:m, j)
22  if ~central
23    j = i-1;
24    ps = find(b <= j);
25  end
26  G  = reshape(F(rows(i),rows(j),1:3,1:3),3,3);
27  epip = reshape(ep(rows(i),rows(j),1:3),3,1);
28  for p = ps
29    Ilamb(i,p) = Ilamb(j,p) & ~isnan(M(3*i,p));
30   
31    if Ilamb(i,p)
32      u           = cross(epip,M(3*i-2:3*i,p));         %q(i,p)
33      v           = G*M(3*j-2:3*j,p);                   %q(j,p)
34      lambda(i,p) = u'*v/norm(u)^2*lambda(j,p);
35    else
36      lambda(i,p) = 1; %so that it's possible to recover scene at the end
37    end
38  end
39end
Note: See TracBrowser for help on using the repository browser.