1%% Reset everything
2
3clear all;
4clc;
5close all;
6addpath('helpers');
7
8%% Configure the benchmark
9
10% central case -> only one camera
11cam_number = 4;
12% Getting 17 points, and testing all algorithms with the respective number of points
13pt_number = 17;
14% noise test, so no outliers
15outlier_fraction = 0.0;
16% repeat 1000 iterations
17iterations = 1000;
18
19% The algorithms we want to test
20algorithms = { 'sixpt'; 'ge'; 'seventeenpt' };
21% This defines the number of points used for every algorithm
22indices = { [1:1:6]; [1:1:8]; [1:1:17] };
23% The name of the algorithms in the final plots
24names = { '6pt';'ge (8pt)'; '17pt' };
25
26% The noise in this experiment
27noise = 0.5;
28
29%% Run the benchmark
30
31%prepare the overall result arrays
32num_algorithms = size(algorithms,1);
33execution_times = zeros(num_algorithms,iterations);
34counter = 0;
35
36for i=1:iterations
37
38    % generate experiment
39    [v1,v2,t,R] = create2D2DOmniExperiment(pt_number,cam_number,noise,outlier_fraction);
40    [t_perturbed,R_perturbed] = perturb(t,R,0.01);
41    T_perturbed = [R_perturbed,t_perturbed];
42    T_init = [eye(3) zeros(3,1)];
43
44    for a=1:num_algorithms
45        tic
46        Out = opengv_donotuse(algorithms{a},indices{a},v1,v2,T_init);
47        execution_times(a,i) = toc/20.0;
48    end
49
50    counter = counter + 1;
51    if counter == 1
52        counter = 0;
53        display(['Iteration ' num2str(i) ' of ' num2str(iterations) '(noise level ' num2str(noise) ')']);
54    end
55end
56
57%% Plot results
58
59hist(log10(execution_times)')
60
61legend(names,'Location','NorthWest')
62xlabel('execution time [s]')
63ylabel('occurence')
64grid on
65
66%% print the mean and median execution time on the console
67
68display( 'mean execution times:' )
69display(['sixpt:       ' num2str(mean(execution_times(1,:)'))] );
70display(['ge:          ' num2str(mean(execution_times(2,:)'))] );
71display(['seventeenpt: ' num2str(mean(execution_times(3,:)'))] );
72
73%% Plot the results
74%
75% [y1,x1] = hist(execution_times(1,:));
76% [y2,x2] = hist(execution_times(2,:));
77% [y3,x3] = hist(execution_times(3,:));
78%
79% y1 = y1 / (x1(1,2) - x1(1,1));
80% y2 = y2 / (x2(1,2) - x2(1,1));
81% y3 = y3 / (x3(1,2) - x3(1,1));
82%
83% figure(2)
84% hold on
85% plot(x1,y1,'b');
86% plot(x2,y2,'g');
87% plot(x3,y3,'r');
88% legend(names,'Location','NorthWest')
89% xlabel('execution time [s]')
90% ylabel('probability')
91% grid on
92