% By Philip Torr 2002 % copyright Microsoft Corp. %main() %this script compares two methods for estimating F %select the two methods and place their ID's in the array methods_used % %methods_used = [4,3] %comparing non-linear method with Sampson %methods_used = [4,2] %comparing linear and Hegel methods_used = [2,3,4,6,7,8]; m3 = 256; sse2t = 0; % % randn('state',0) % rand('state',0) no_methods = length(methods_used); foc = 256; best_method_array = zeros(no_methods,1); method_sse = zeros(no_methods,1); method_n_sse = zeros(no_methods,1); epipole_distance = zeros(no_methods,1); oo_vicar = 0; no_matches =100; noise_sigma = 1; translation_mult = foc * 10; translation_adder = 20; %max number of degrees to rotate rotation_multplier = 40; min_Z = 1; Z_RAN = 10; no_tests = 50; min_noise = 1; max_noise = 4; percent_gain = zeros(1,max_noise); ep_percent_gain = zeros(1,max_noise); times = zeros(no_methods,max_noise); for(noise_sigma = min_noise:max_noise) for(i = 1:no_tests) best_sse = 10000000000; best_method = 5; %generate a load of stuffs %F ave_fa_e = 0.0; while ave_fa_e < 0.5 [true_F,x1,y1,x2,y2,nx1,ny1,nx2,ny2,true_C,true_R,true_TX, true_E, true_X, true_t] = ... torr_gen_2view_matches(foc, no_matches, noise_sigma, translation_mult, translation_adder, ... rotation_multplier, min_Z,Z_RAN,m3); [FA, fa] = torr_estfa(x1,y1,x2,y2, no_matches,m3); fa_e = torr_errfa(fa, x1,y1,x2,y2, no_matches, m3); %see what average match looks like ave_fa_e = norm(fa_e,1)/no_matches; if no_tests == 1 ave_fa_e; end end % % if ssse_fa <6.0 % disp('ooo vicar'); % oo_vicar = oo_vicar + 1; % end % %calc true epipole true_epipole = torr_get_right_epipole(true_F,m3); % for method = 2:6 for methodIndex = 1:length(methods_used) method = methods_used(methodIndex); set_rank2 = 1; t = clock; [nf, f_sq_errors, n_inliers,inlier_index,nF] ... = torr_estimateF( [nx1,ny1,nx2,ny2], m3, [], method,set_rank2); times(methodIndex,noise_sigma) = times(methodIndex,noise_sigma)+etime(clock,t); %calc noisy epipole noisy_epipole = torr_get_right_epipole(nF,m3); epipole_distance(methodIndex) = epipole_distance(methodIndex) + sqrt(norm(true_epipole -noisy_epipole)); pe = torr_errf2(nf,x1,y1,x2,y2, no_matches, m3); n_e = torr_errf2(nf,nx1,ny1,nx2,ny2, no_matches, m3); sse_n = norm(pe); if (sse_n < best_sse) best_method = methodIndex; best_sse = sse_n; end method_sse(methodIndex) = method_sse(methodIndex) + sse_n; method_n_sse(methodIndex) = method_n_sse(methodIndex) + norm(n_e); end %method = 1:4 best_method_array(best_method) = best_method_array(best_method)+1; end disp('best_method_array is '); best_method_array' disp('method_sse is'); (method_sse/(no_tests*length(x1)))' disp('method_n_sse is'); (method_n_sse/(no_tests*length(x1)))' for methodIndex = 1:length(methods_used) percent_gain(methodIndex,noise_sigma) = method_sse(1)/method_sse(methodIndex); ep_percent_gain(methodIndex,noise_sigma) = epipole_distance(1)/epipole_distance(methodIndex); end end disp('percentage gain of error'); 100 * percent_gain disp('which averages to'); 100 * mean(percent_gain,2) disp('ratio of epipole error'); 100 * ep_percent_gain disp('which averages to'); 100 * mean(ep_percent_gain,2) disp('number of times gets lowest errors'); best_method_array disp('times'); times disp('which averages to'); mean(times,2) disp('The methods are'); methods_used