-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathe4NuScenesPlot.m
186 lines (155 loc) · 6.86 KB
/
e4NuScenesPlot.m
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
%% Specific plots and evaluations for RAL-Radar Paper
%
% Evaluation Example:
% "nuScenes"
%
% Corresponding Publication:
% "A Credible and Robust approach to Ego-Motion Estimation using an
% Automotive Radar" (<a href="https://mytuc.org/creme">details</a>)
%
% @author Sven Lange (TU Chemnitz, ET/IT, Prozessautomatisierung)
% This file is part of
% CREME - Credible Radar Ego-Motion Estimation
%
% Copyright (C) 2022 Chair of Automation Technology / TU Chemnitz
% For more information see https://mytuc.org/creme
%
% CREME is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% CREME is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this software. If not, see <http://www.gnu.org/licenses/>.
%
% Contact Information: Sven Lange ([email protected])
function [eval] = e4NuScenesPlot(eName,workingFolder,dataFolder)
%E4NUSCENESPLOT Generate the plots and evaluations for nuScenes.
% If eName is given as a cell instead of a char, these scenes will be
% concatinated.
% Get all available scenes by json
%files = dir('e4NuScenes_*.json'); files = string({files.name});
%a=arrayfun(@(x)length(regexp(x,'\w+_(\d+)\.json','tokens','once')),files,'UniformOutput',true)
%arrayfun(@(x)string(regexp(x,'\w+_(\d+)\.json','tokens','once')),files(logical(a)),'UniformOutput',true)
eNameDefault = {'0061', '0103', '0553', '0655', '0757', '0796', '0916', '1077', '1094', '1100'};
if nargin < 1, eName = eNameDefault; end % Default value
if nargin < 2 || isempty(workingFolder), workingFolder = fileparts(mfilename('fullpath')); end
if nargin < 3, dataFolder = 'e4Data'; end
eFolderTemplate = fullfile(workingFolder, dataFolder, 'NuScenes%ENAME%');
if iscell(eName)
% We want to merge multiple scenes
f = strrep(eFolderTemplate, '%ENAME%', eName{1});
[e1, results1, e1_p] = libmix4sam.registration.loadRegistrationExperiment(f);
e1 = {e1}; e1_p.datasetScene = [];
for iScene = 2:length(eName)
f = strrep(eFolderTemplate, '%ENAME%', eName{iScene});
[e1{iScene}, resultsNew, e_p] = libmix4sam.registration.loadRegistrationExperiment(f);
results1 = mergeResults(results1,resultsNew);
e1_p.name(iScene) = e_p.name;
e1_p.size = [e1_p.size e_p.size];
end
eName = 'multiple'; %cell2mat(eName); % For result name later on.
else
[e1, results1, e1_p] = libmix4sam.registration.loadRegistrationExperiment(...
strrep(eFolderTemplate, '%ENAME%', eName));
end
%% Select specific scene-result out of multiple scenes.
% Use [] as scene name, if all should be selected!
%disp('available scenes:'); fprintf('%s\n',e1_p.name)
onlyScene = []; % e.g. [] or "scene-0553";
[e1, results1] = selectScene(onlyScene, e1, results1, e1_p);
%% Fill evaluation class with the results
% Define a working folder to save the output, leave it empty otherwise.
% e.g. [] or fullfile(workingFolder, dataFolder, ['NuScenes' char(eName) '_results'])
workingFolder = fullfile(workingFolder, dataFolder, ['NuScenes' char(eName) '_results']);
eval = libmix4sam.registration.EvalRadarExperiment();
eval.addExperimentData(e1);
eval.addResultData(results1);
if nargout > 0, return; end % We only want the eval class instance.
eval.procAccuracy(); % Accuracy analysis
eval.procCredibility(); % Credibility / Confidence analysis
%% Create plots and save
hPlots = struct('Name',{},'Handle',{});
hPlots(end+1).Name = 'ErrorOverTime';
[hPlots(end).Handle, ax] = eval.plotErrorOverTime();
showSceneSegments(ax, onlyScene, e1_p)
hPlots(end+1).Name = 'AccuracyErrorPlot';
[hPlots(end).Handle, ax] = eval.Accuracy.plotError();
for i = findobj(ax.TransHist,'Type','Histogram'), set(i,'BinWidth',0.01), end
hPlots(end+1).Name = 'CredibilityNEESComparison';
hPlots(end).Handle = eval.Credibility.plotNEESComparison();
% Make the plot a bit nicer
neesplot = libmix4sam.utils.PlotNice(hPlots(end).Handle);
neesplot.setCommonBinWidth(0.1);
neesplot.setCommonLimits([0 10],[0 1]);
neesplot.subVertCommonX();
if numel(e1_p.size) == 1
hPlots(end+1).Name = 'Trajectory';
hPlots(end).Handle = eval.plotTrajectory();
end
hPlots(end+1).Name = 'OutlierAnalysis';
hPlots(end).Handle = eval.plotOutlierAnalysis();
if ~isempty( workingFolder )
if ~exist( workingFolder, 'dir'), mkdir(workingFolder); end
for iPlot = 1:numel(hPlots)
savefig( hPlots(iPlot).Handle,...
fullfile(workingFolder, [hPlots(iPlot).Name '.fig']),'compact');
end
end
%% Create tables and save
TAccuracy = eval.Accuracy.showComparisonTable()
TCredibility = eval.Credibility.showComparisonTable()
TAdditional = eval.tableAdditional()
if ~isempty( workingFolder )
fname = fullfile(workingFolder,'result.xls');
writetable(TAccuracy, fname, 'Sheet', 'Accuracy' , 'WriteRowNames', true);
writetable(TCredibility, fname, 'Sheet', 'Credibility', 'WriteRowNames', true);
writetable(TAdditional, fname, 'Sheet', 'Additional' , 'WriteRowNames', true);
end
end
%% DEBUGGING
%eval.plotOneProblem(1,110,1); % LMset, ExperimentNr, ResultSet
function [e1, results1] = selectScene(sceneName, e1, results1, e1_p)
if isempty(sceneName) || ~iscell(e1)
% FLATTEN Experiment in case multiple scenes were selected
if iscell(e1), e1 = cell2mat(e1'); end
return;
end
idx = find(ismember(e1_p.name,sceneName),1);
e1 = e1{idx};
slices = [0 cumsum(e1_p.size)];
m = false(slices(end),1);
m((slices(idx)+1):slices(idx+1)) = true;
for i=1:length(results1)
results1(i).data(~m) = [];
end
end
function showSceneSegments(ax,onlyScene,e1_p)
if numel(ax) > 1
for i=1:numel(ax), showSceneSegments(ax(i),onlyScene,e1_p); end
return
end
if ~isempty(onlyScene) % Show title of scene only
%TODO
return
end
slices = [0 cumsum(e1_p.size)]+1;
for iSlice = 1:numel(e1_p.size)
a = xline(ax, slices(iSlice),'k--',num2cell(e1_p.name(iSlice).split('-')),'LabelOrientation','horizontal');
set(get(get(a,'Annotation'),'LegendInformation'),'IconDisplayStyle','off');
end
end
function results = mergeResults(results, result2)
for iRes = 1:length(result2)
% Search for the corresponding result
idx = find(contains({results.name},result2(iRes).name));
assert(~isempty(idx),'The structure of the result to add does not match the other one!');
results(idx).data = [results(idx).data; result2(iRes).data];
results(idx).timing = results(idx).timing + result2(iRes).timing;
end
end