1 | % By Philip Torr 2002
|
---|
2 | % copyright Microsoft Corp.
|
---|
3 | %
|
---|
4 | % %designed for the good of the world by Philip Torr based on ideas contained in
|
---|
5 | % copyright Philip Torr and Microsoft Corp 2002
|
---|
6 | %
|
---|
7 |
|
---|
8 |
|
---|
9 | % /*
|
---|
10 | %
|
---|
11 | % @inproceedings{Torr93b,
|
---|
12 | % author = "Torr, P. H. S. and Murray, D. W.",
|
---|
13 | % title = "Outlier Detection and Motion Segmentation",
|
---|
14 | % booktitle = "Sensor Fusion VI",
|
---|
15 | % editor = "Schenker, P. S.",
|
---|
16 | % publisher = "SPIE volume 2059",
|
---|
17 | % note = "Boston",
|
---|
18 | % pages = {432-443},
|
---|
19 | % year = 1993 }
|
---|
20 | %
|
---|
21 | %
|
---|
22 | % @phdthesis{Torr:thesis,
|
---|
23 | % author="Torr, P. H. S.",
|
---|
24 | % title="Outlier Detection and Motion Segmentation",
|
---|
25 | % school=" Dept. of Engineering Science, University of Oxford",
|
---|
26 | % year=1995}
|
---|
27 | %
|
---|
28 | %
|
---|
29 | %
|
---|
30 | % @article{Torr97c,
|
---|
31 | % author="Torr, P. H. S. and Murray, D. W. ",
|
---|
32 | % title="The Development and Comparison of Robust Methods for Estimating the Fundamental Matrix",
|
---|
33 | % journal="IJCV",
|
---|
34 | % volume = 24,
|
---|
35 | % number = 3,
|
---|
36 | % pages = {271--300},
|
---|
37 | % year=1997
|
---|
38 | % }
|
---|
39 | %
|
---|
40 | %
|
---|
41 | %
|
---|
42 | %
|
---|
43 | % @article{Torr99c,
|
---|
44 | % author = "Torr, P. H. S. and Zisserman, A",
|
---|
45 | % title ="MLESAC: A New Robust Estimator with Application to Estimating Image Geometry ",
|
---|
46 | % journal = "CVIU",
|
---|
47 | % Volume = {78},
|
---|
48 | % number = 1,
|
---|
49 | % pages = {138-156},
|
---|
50 | % year = 2000}
|
---|
51 |
|
---|
52 | %threshold is the maximum squared value of the residuals
|
---|
53 | %no_matches is the number of matches
|
---|
54 | %no_samp is the number of random samples to be taken
|
---|
55 | %m3 is the estimate of the 3rf projective coordinate (f in pixels)
|
---|
56 |
|
---|
57 | %the F matrix is defined like:
|
---|
58 | % (nx2, ny2, m3) f(1 2 3) nx1
|
---|
59 | % (4 5 6) ny1
|
---|
60 | % (7 8 9) m3
|
---|
61 |
|
---|
62 |
|
---|
63 |
|
---|
64 | %we minimize a robust function min(e^2,T) see MLESAC paper.
|
---|
65 |
|
---|
66 |
|
---|
67 | function f = torr_mlesac_F(x1,y1,x2,y2, no_matches, m3, no_samp, T)
|
---|
68 | %disp('This just does calculation of perfect data,for test')
|
---|
69 | %disp('Use estf otherwise')
|
---|
70 | %f = rand(9);
|
---|
71 |
|
---|
72 |
|
---|
73 | for(i = 1:no_samp)
|
---|
74 | choice = randperm(no_matches);
|
---|
75 | %set up local design matrix, here we estimate from 7 matches
|
---|
76 | for (j = 1:7)
|
---|
77 | tx1(j) = x1( choice(j));
|
---|
78 | tx2(j) = x2( choice(j));
|
---|
79 | ty1(j) = y1( choice(j));
|
---|
80 | ty2(j) = y2( choice(j));
|
---|
81 | end % for (j = 1:7)
|
---|
82 |
|
---|
83 |
|
---|
84 | %produces 1 or 3 solutions.
|
---|
85 | [no_F big_result]= torr_F_constrained_fit(tx1,ty1,tx2,ty2,m3);
|
---|
86 |
|
---|
87 | for j = 1:no_F
|
---|
88 | ft = big_result(j,:);
|
---|
89 |
|
---|
90 | %get squared errors
|
---|
91 | et = torr_errf2(ft,x1,y1,x2,y2, no_matches, m3);
|
---|
92 | %capped residuals
|
---|
93 | cet = min(et,T);
|
---|
94 | sse = cet' * cet;
|
---|
95 | % use sse 0 to bring it to a reasonable value
|
---|
96 | if ((i ==1) & (j ==1))
|
---|
97 | f = ft;
|
---|
98 | bestsse = sse;
|
---|
99 | elseif bestsse > sse
|
---|
100 | f = ft;
|
---|
101 | bestsse = sse;
|
---|
102 | end
|
---|
103 |
|
---|
104 | end
|
---|
105 |
|
---|
106 | end %for(i = 1:no_samp)
|
---|
107 |
|
---|
108 |
|
---|
109 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
110 |
|
---|