source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/MultiCamSelfCal/Ransac/rEG.m @ 37

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

Added original make3d

File size: 1.6 KB
Line 
1function [F, inls] = rEG(u, th, th7, conf)
2
3%rEG     Robust computation of epipolar geometry based on RANSAC
4%
5% [F, inls] = rEG(u, th, th7, conf)
6% u    point correspondences (6xn), where n is the number of corrs.
7% th   threshold value for the Sampson's distance (see FDs)
8% th7  threshold for inliers to iterate on F (default = th)
9% conf confidence level of self-termination  (default = .95)
10
11MAX_SAM = 100000;
12iter_amount = .5;
13
14if nargin < 3
15  th7 = th;
16end;
17
18if nargin < 4
19  conf = .95;
20end;
21
22len = size(u,2);
23ptr = 1:len;
24max_i = 8;
25max_sam = MAX_SAM;
26 
27no_sam = 0;
28no_mod = 0;
29 
30while no_sam < max_sam
31  for pos = 1:7
32      idx = pos + ceil(rand * (len-pos));
33      ptr([pos, idx]) = ptr([idx, pos]);
34  end;
35 
36  no_sam = no_sam +1;
37 
38  aFs = fu2F7(u(:,ptr(1:7)));
39 
40  for i = 1:size(aFs,3)
41      no_mod = no_mod +1;
42      aF = aFs(:,:,i);
43          Ds = mfFDs(aF,u);
44          % Ds = fFDs(aF,u);
45      v  = Ds < th;
46      v7 = Ds < th7;
47      no_i  = sum(v);
48     
49      if max_i < no_i
50        inls = v;
51        F = aF;
52        max_i = no_i;
53        max_sam = min([max_sam,nsamples(max_i, len, 7, conf)]);
54      end 
55
56      if sum(v7) >= 8 + iter_amount*(max_i - 8)
57        aF = u2F(u(:,v7));
58        Ds = mfFDs(aF,u);
59                % Ds = fFDs(aF,u);
60        v  = Ds < th;
61        no_i = sum(v);
62        if max_i < no_i
63          inls = v;
64          F = aF;
65          max_i = no_i;
66          exp_sam = nsamples(max_i, len, 7, .95);
67          max_sam = min([max_sam,exp_sam]);
68        end 
69      end
70  end
71end
72
73if no_sam == MAX_SAM
74  warning(sprintf('RANSAC - termination forced after %d samples expected number of samples is %d',  no_sam, exp_sam));
75end;
76
77
78     
79     
80     
81
82
83
84
85
Note: See TracBrowser for help on using the repository browser.