File: benchmark_absolute_pose_execution_times.m

package info (click to toggle)
opengv 1.0%2B1git91f4b1-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,480 kB
  • sloc: cpp: 45,813; python: 152; makefile: 17; xml: 13; sh: 4
file content (65 lines) | stat: -rw-r--r-- 1,712 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
%% Reset everything

clear all;
clc;
close all;
addpath('helpers');

%% Configure the benchmark

% central case -> only one camera
cam_number = 1;
% let's only get 6 points, and generate new ones in each iteration
pt_number = 50;
% noise test, so no outliers
outlier_fraction = 0.0;
% repeat 1000 iterations
iterations = 1000;

% The algorithms we want to test
algorithms = { 'p2p'; 'p3p_kneip'; 'p3p_gao'; 'epnp'; 'upnp' };
% This defines the number of points used for every algorithm
indices = { [1, 2]; [1, 2, 3]; [1, 2, 3]; [1:1:50]; [1:1:50] };
% The name of the algorithms on the plots
names = { 'P2P'; 'P3P (Kneip)'; 'P3P (Gao)'; 'EPnP (50pts)'; 'UPnP (50pts)'};

% The noise in this experiment
noise = 1.0;

%% Run the benchmark

%prepare the overall result array
num_algorithms = size(algorithms,1);
execution_times = zeros(num_algorithms,iterations);
counter = 0;

for i=1:iterations
    
    % generate experiment
    [points,v,t,R] = create2D3DExperiment(pt_number,cam_number,noise,outlier_fraction);
    [t_perturbed,R_perturbed] = perturb(t,R,0.01);
    T_perturbed = [R_perturbed,t_perturbed];
    
    % run all algorithms
    for a=1:num_algorithms
        tic;
        T = opengv_donotuse(algorithms{a},indices{a},points,v,T_perturbed);
        execution_times(a,i) = toc/20.0;
    end
    
    counter = counter + 1;
    if counter == 100
        counter = 0;
        display(['Iteration ' num2str(i) ' of ' num2str(iterations)]);
    end
end

%% Plot the results

bins = [0.000001:0.000001:0.00001];
hist(execution_times',bins)
legend(names,'Location','NorthWest')
xlabel('execution times [s]')
grid on

mean(execution_times')