1%% Reset everything 2 3clear all; 4clc; 5close all; 6addpath('helpers'); 7 8rng shuffle 9 10%% Configure the benchmark 11 12% noncentral case 13cam_number = 4; 14% Getting 10 points, and testing all algorithms with the respective number of points 15pt_per_cam = 20; 16% outlier test, so constant noise 17noise = 0.5; 18% repeat 100 tests per outlier-ratio 19iterations = 50; 20 21% The algorithms we want to test 22algorithms = [ 0; 1; 2 ]; 23% The name of the algorithms in the final plots 24names = { '6pt'; 'ge (8pt)'; '17pt'}; 25 26% The main experiment parameters 27min_outlier_fraction = 0.05; 28max_outlier_fraction = 0.45; 29outlier_fraction_step = 0.05; 30 31%% Run the benchmark 32 33%prepare the overall result arrays 34number_outlier_fraction_levels = round((max_outlier_fraction - min_outlier_fraction) / outlier_fraction_step + 1); 35num_algorithms = size(algorithms,1); 36 37%Run the experiment 38for n=1:number_outlier_fraction_levels 39 40 outlier_fraction = (n - 1) * outlier_fraction_step + min_outlier_fraction; 41 display(['Analyzing outlier fraction level: ' num2str(outlier_fraction)]) 42 43 clear number_iterations 44 clear execution_times 45 46 counter = 0; 47 48 temp_file_name1 = ['number_iterations_' num2str(outlier_fraction) '.mat']; 49 temp_file_name2 = ['execution_times_' num2str(outlier_fraction) '.mat']; 50 51 if exist(temp_file_name1,'file') > 0 52 display(['number_iterations_' num2str(outlier_fraction) '.mat exists already']) 53 load(temp_file_name1) 54 load(temp_file_name2) 55 startingIteration = size(number_iterations,2) + 1; 56 display(['starting at ' num2str(startingIteration)]) 57 else 58 startingIteration = 1; 59 end 60 61 if startingIteration <= iterations 62 for i=startingIteration:iterations 63 64 % generate experiment 65 [v1,v2,cam_offsets,t,R] = createMulti2D2DOmniExperiment(pt_per_cam,cam_number,noise,outlier_fraction); 66 67 for a=1:num_algorithms 68 69 if strcmp(names{a,1},'6pt') && outlier_fraction > 0.25 70 Out = zeros(4,5); 71 time = 10000000.0; 72 else 73 tic 74 Out = opengv_experimental1( v1{1,1}, v1{2,1}, v1{3,1}, v1{4,1}, v2{1,1}, v2{2,1}, v2{3,1}, v2{4,1}, cam_offsets, algorithms(a,1) ); 75 time = toc; 76 end 77 78 number_iterations(a,i) = Out(1,5); 79 execution_times(a,i) = time; 80 end 81 82 save(temp_file_name1,'number_iterations'); 83 save(temp_file_name2,'execution_times'); 84 85 counter = counter + 1; 86 if counter == 1 87 counter = 0; 88 display(['Iteration ' num2str(i) ' of ' num2str(iterations) '(outlier_fraction level ' num2str(outlier_fraction) ')']); 89 end 90 end 91 end 92end