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 66 67 68 69 70 71 72 73 74 75 76 77 78
|
%% Reset everything
clear all;
clc;
close all;
addpath('helpers');
%% Configure the benchmark
% noncentral case
cam_number = 4;
% set maximum and minimum number of points per cam
pt_number_per_cam = 50;
% set maximum and minimum number of outliers
min_outlier_fraction = 0.1;
max_outlier_fraction = 0.2;
% repeat 10000 iterations
iterations = 1000;
% The name of the algorithms in the final plots
names = { 'Homogeneous'; 'Vanilla' };
% The noise in this experiment
noise = 0.5;
%% Run the benchmark
%prepare the overall result arrays
ransac_iterations = zeros(2,iterations);
%Run the RANSAC with homogeneous sampling
counter = 0;
for i=1:iterations
%generate random outlier fraction
outlier_fraction = rand() * (max_outlier_fraction - min_outlier_fraction) + min_outlier_fraction;
% generate experiment
[v1,v2,cam_offsets,t,R] = createMulti2D2DExperiment(pt_number_per_cam,cam_number,noise,outlier_fraction);
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, 2 );
ransac_iterations(1,i) = Out(1,5);
counter = counter + 1;
if counter == 100
counter = 0;
display(['Homogeneous sampling: Iteration ' num2str(i) ' of ' num2str(iterations)]);
end
end
%Run the RANSAC with vanilla sampling
counter = 0;
for i=1:iterations
%generate random outlier fraction
outlier_fraction = rand() * (max_outlier_fraction - min_outlier_fraction) + min_outlier_fraction;
% generate experiment
[v1,v2,t,R] = create2D2DExperiment(pt_number_per_cam*cam_number,cam_number,noise,outlier_fraction);
Out = opengv_experimental2( v1, v2, 2 );
ransac_iterations(2,i) = Out(1,5);
counter = counter + 1;
if counter == 100
counter = 0;
display(['Vanilla sampling: Iteration ' num2str(i) ' of ' num2str(iterations)]);
end
end
%% Plot the results
figure(1)
hist(ransac_iterations')
[Y,X] = hist(ransac_iterations')
legend(names,'Location','NorthEast')
xlabel('number of iterations')
grid on
|