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