[37] | 1 | % By Philip Torr 2002
|
---|
| 2 | % copyright Microsoft Corp.
|
---|
| 3 | %main()
|
---|
| 4 |
|
---|
| 5 | m3 = 256;
|
---|
| 6 | sse2t = 0;
|
---|
| 7 | %
|
---|
| 8 | % randn('state',0)
|
---|
| 9 | % rand('state',0)
|
---|
| 10 |
|
---|
| 11 | no_methods = 6;
|
---|
| 12 | foc = 256;
|
---|
| 13 | best_method_array = zeros(no_methods,1);
|
---|
| 14 | method_sse = zeros(no_methods,1);
|
---|
| 15 | method_n_sse = zeros(no_methods,1);
|
---|
| 16 | epipole_distance = zeros(no_methods,1);
|
---|
| 17 | oo_vicar = 0;
|
---|
| 18 |
|
---|
| 19 | no_matches =100;
|
---|
| 20 | noise_sigma = 1;
|
---|
| 21 | translation_mult = foc * 10;
|
---|
| 22 | translation_adder = 20;
|
---|
| 23 |
|
---|
| 24 | %max number of degrees to rotate
|
---|
| 25 | rotation_multplier = 40;
|
---|
| 26 | min_Z = 1;
|
---|
| 27 | Z_RAN = 10;
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | no_tests = 20;
|
---|
| 33 | %methods_used = [4,3]
|
---|
| 34 |
|
---|
| 35 | %comparing non-linear method with Sampson
|
---|
| 36 | methods_used = [4,2]
|
---|
| 37 |
|
---|
| 38 | min_noise = 1;
|
---|
| 39 | max_noise = 20;
|
---|
| 40 | percent_gain = zeros(1,max_noise);
|
---|
| 41 | ep_percent_gain = zeros(1,max_noise);
|
---|
| 42 |
|
---|
| 43 | for(noise_sigma = min_noise:max_noise)
|
---|
| 44 | for(i = 1:no_tests)
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | best_sse = 10000000000;
|
---|
| 48 | best_method = 5;
|
---|
| 49 |
|
---|
| 50 | %generate a load of stuffs
|
---|
| 51 | %F
|
---|
| 52 |
|
---|
| 53 | ave_fa_e = 0.0;
|
---|
| 54 | while ave_fa_e < 0.5
|
---|
| 55 |
|
---|
| 56 | [true_F,x1,y1,x2,y2,u1,v1,nx1,ny1,nx2,ny2] = ...
|
---|
| 57 | torr_gen_2view_matches(foc, no_matches, noise_sigma, translation_mult, translation_adder, ...
|
---|
| 58 | rotation_multplier, min_Z,Z_RAN,m3);
|
---|
| 59 | [FA, fa] = torr_estfa(x1,y1,x2,y2, no_matches,m3);
|
---|
| 60 | fa_e = torr_errfa(fa, x1,y1,x2,y2, no_matches, m3);
|
---|
| 61 |
|
---|
| 62 | %see what average match looks like
|
---|
| 63 |
|
---|
| 64 | ave_fa_e = norm(fa_e,1)/no_matches;
|
---|
| 65 | if no_tests == 1
|
---|
| 66 | ave_fa_e;
|
---|
| 67 | end
|
---|
| 68 |
|
---|
| 69 | end
|
---|
| 70 | %
|
---|
| 71 | % if ssse_fa <6.0
|
---|
| 72 | % disp('ooo vicar');
|
---|
| 73 | % oo_vicar = oo_vicar + 1;
|
---|
| 74 | % end
|
---|
| 75 | % %calc true epipole
|
---|
| 76 | true_epipole = torr_get_right_epipole(true_F,m3);
|
---|
| 77 |
|
---|
| 78 | % for method = 2:6
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | for method = methods_used
|
---|
| 82 |
|
---|
| 83 | X1 = [x1,y1, ones(length(x1),1) * m3];
|
---|
| 84 | X2 = [x2,y2, ones(length(x2),1) * m3];
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | %error on perfect data (should be zero)
|
---|
| 88 | %f = estf(nx1,ny1,nx2,ny2, no_matches,m3);
|
---|
| 89 | %f = estf(x1,y1,x2,y2, no_matches,m3);
|
---|
| 90 | %
|
---|
| 91 | % [F , f]= fm_linear(X1, X2, eye(3), method);
|
---|
| 92 | % e = torr_errf2(f,x1,y1,x2,y2, no_matches, m3);
|
---|
| 93 | % disp('noise free error (sanity check)')
|
---|
| 94 | % ssep = e' * e
|
---|
| 95 | %
|
---|
| 96 | % %error on noisy data
|
---|
| 97 | % f = fm_linear(nx1,ny1,nx2,ny2, no_matches,m3);
|
---|
| 98 | % e = torr_errf2(f,nx1,ny1,nx2,ny2, no_matches, m3);
|
---|
| 99 | % ssen = e * e'
|
---|
| 100 |
|
---|
| 101 | nX1 = [nx1,ny1, ones(length(x1),1) * m3];
|
---|
| 102 | nX2 = [nx2,ny2, ones(length(x2),1) * m3];
|
---|
| 103 |
|
---|
| 104 | % [nF , nf]= fm_linear(nX1, nX2, eye(3), method);
|
---|
| 105 | set_rank2 = 1;
|
---|
| 106 | [nf, nF ] = torr_estimateF(nx1,ny1,nx2,ny2, no_matches, m3, method,set_rank2);
|
---|
| 107 |
|
---|
| 108 | %calc noisy epipole
|
---|
| 109 | noisy_epipole = torr_get_right_epipole(nF,m3);
|
---|
| 110 | epipole_distance(method) = epipole_distance(method) + sqrt(norm(true_epipole -noisy_epipole));
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | torr_error = 1;
|
---|
| 114 | if torr_error
|
---|
| 115 | pe = torr_errf2(nf,x1,y1,x2,y2, no_matches, m3);
|
---|
| 116 | n_e = torr_errf2(nf,nx1,ny1,nx2,ny2, no_matches, m3);
|
---|
| 117 | else
|
---|
| 118 | CC = eye(3);
|
---|
| 119 | CC(3,3) = m3;
|
---|
| 120 | nF2 = CC * nF * CC;
|
---|
| 121 |
|
---|
| 122 | n1 = [x1 y1];
|
---|
| 123 | n2= [x2 y2];
|
---|
| 124 | nowarn = 0;
|
---|
| 125 |
|
---|
| 126 | ne = fm_error_hs(nF, n1, n2, nowarn);
|
---|
| 127 | end
|
---|
| 128 | % ne = torr_errf2(nf,nx1,ny1,nx2,ny2, no_matches, m3);
|
---|
| 129 |
|
---|
| 130 | % disp('trimmed noisy error on noise free points')
|
---|
| 131 | % sse_n = ne' * ne
|
---|
| 132 |
|
---|
| 133 | sse_n = norm(pe);
|
---|
| 134 |
|
---|
| 135 | if (sse_n < best_sse)
|
---|
| 136 | best_method = method;
|
---|
| 137 | best_sse = sse_n;
|
---|
| 138 | end
|
---|
| 139 |
|
---|
| 140 | method_sse(method) = method_sse(method) + sse_n;
|
---|
| 141 | method_n_sse(method) = method_sse(method) + norm(n_e);
|
---|
| 142 |
|
---|
| 143 | end %method = 1:4
|
---|
| 144 | best_method_array(best_method) = best_method_array(best_method)+1;
|
---|
| 145 | end
|
---|
| 146 |
|
---|
| 147 |
|
---|
| 148 | % %mine
|
---|
| 149 | % f_torr = estf(nx1,ny1,nx2,ny2, no_matches,m3);
|
---|
| 150 | % ne = torr_errf2(f_torr,x1,y1,x2,y2, no_matches, m3);
|
---|
| 151 | % disp('noisy error on noise free points')
|
---|
| 152 | % sse_n = norm(ne(20:no_matches-20))
|
---|
| 153 |
|
---|
| 154 | %disp('trace = 1, trace =0, ls, det = 1, 2x2 = 1, 2x2 =1')
|
---|
| 155 |
|
---|
| 156 | best_method_array(methods_used)';
|
---|
| 157 | (method_sse(methods_used)/(no_tests*length(x1)))';
|
---|
| 158 | (method_n_sse(methods_used)/(no_tests*length(x1)))';
|
---|
| 159 |
|
---|
| 160 | percent_gain(noise_sigma) = method_sse(methods_used(1))/method_sse(methods_used(2));
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 |
|
---|
| 165 | %disp('distance to true epipole');
|
---|
| 166 | (epipole_distance(methods_used)/no_tests)';
|
---|
| 167 |
|
---|
| 168 | ep_percent_gain(noise_sigma) = epipole_distance(methods_used(1))/epipole_distance(methods_used(2));
|
---|
| 169 |
|
---|
| 170 | %oo_vicar
|
---|
| 171 | %display_mat(perfect_matches, x1,y1, u1, v1)
|
---|
| 172 | %
|
---|
| 173 |
|
---|
| 174 | % e = fm_error_hs(F, n1, n2, nowarn);
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | %torr_display_epipoles(nF,nF,perfect_matches, x1,y1, u1, v1)
|
---|
| 178 | end
|
---|
| 179 |
|
---|
| 180 | disp('ratio of error');
|
---|
| 181 | 100 * percent_gain
|
---|
| 182 |
|
---|
| 183 | disp('ratio of epipole error');
|
---|
| 184 | 100 * ep_percent_gain |
---|