-
Notifications
You must be signed in to change notification settings - Fork 1
/
plotConvexSolverResults.m
186 lines (165 loc) · 6.28 KB
/
plotConvexSolverResults.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
function data_t = plotConvexSolverResults(opts, problem, ...
axes_h, fig_h, colors, iter, data_t, out_t, res_t)
if isempty(problem)
problem.sim = 1;
problem.noise = -1;
end
if isempty(axes_h) || isempty(fig_h)
[axes_h, fig_h] = createFigHandleWithNumber(4, 30, ...
"simRCQP", 1, 1);
end
if isempty(colors)
colors = getColors(length(1));
end
if isempty(iter)
iter = 1;
end
if problem.sim && opts.solver == 1
% initial status
cur_axes = 1;
cur_fig =1;
opts.plotting.model = 1;
opts.plotting.corrected_source = 0;
opts.plotting.corrected2target = 0;
opts.plotting.source2target = 0;
opts.plotting.source_points = 1;
title_txt = "Optimization cost and scaling is " ...
+ "(" + num2str(abs(out_t.f)) ...
+ ", " + num2str(out_t.s) + ")";
plotCorrespondences(opts, axes_h, cur_axes, ...
out_t.centroid_t.point, ...
data_t.correspondences, out_t.sim, out_t.s, title_txt)
drawnow
% results
cur_axes = 2;
cur_fig = 2;
opts.plotting.model = 1;
opts.plotting.corrected_source = 1;
opts.plotting.corrected2target = 0;
opts.plotting.source2target = 0;
opts.plotting.source_points = 0;
title_txt = "Optimization cost and scaling is " ...
+ "(" + num2str(abs(out_t.f)) ...
+ ", " + num2str(out_t.s) + ")";
plotCorrespondences(opts, axes_h, cur_axes, ...
out_t.centroid_t.point, ...
data_t.correspondences, out_t.sim, out_t.s, title_txt)
fprintf("Noise level: %.2f\n", problem.noise)
out_t.sim.sim
if isfield(data_t, 'gt_T')
data_t.gt_T.sim
geo_dis = norm(data_t.gt_T.sim \ out_t.sim.sim);
fprintf("Geodestic: %.3f\n", geo_dis)
data_t.geo_dis = geo_dis;
end
data_t.out_t = out_t;
elseif problem.sim && opts.solver == 2
% initial
cur_axes = 1;
cur_fig =1;
opts.plotting.model = 1;
opts.plotting.corrected_source = 0;
opts.plotting.corrected2target = 0;
opts.plotting.source2target = 0;
opts.plotting.source_points = 1;
if isfield(data_t, 'gt_T')
title_txt = "Original scaling: " + num2str(data_t.gt_T.s);
else
title_txt = "Original";
end
plotCorrespondences(opts, axes_h, cur_axes, ...
[], ...
data_t.correspondences, out_t.sim, out_t.s, title_txt)
drawnow
% results
cur_axes = 2;
cur_fig = 2;
opts.plotting.model = 0;
opts.plotting.corrected_source = 1;
opts.plotting.corrected2target = 1;
opts.plotting.source2target = 0;
opts.plotting.source_points = 0;
title_txt = "Optimization cost and scaling is " ...
+ "(" + num2str(abs(out_t.f)) ...
+ ", " + num2str(out_t.s) + ")";
plotCorrespondences(opts, axes_h, cur_axes, ...
[], ...
data_t.correspondences, out_t.sim, out_t.s, title_txt)
drawnow
cur_axes = 3;
cur_fig = 3;
s_v = [res_t(:).s];
d_star_v = [res_t(:).dstar];
f_v = [res_t(:).f];
data_t.fig_h = scatter(axes_h(cur_axes), s_v, d_star_v, [], ...
colors{iter}, 'o');
data_t.fig_txt = "noise = " + num2str(problem.noise);
% h(i) = scatter(axes_h(cur_axes), s_v, d_star_v, [], ...
% colors{i}, 'o', 'DisplayName', "noise = " + num2str(noise));
% legend(h(i));
scatter(axes_h(cur_axes), s_v, f_v, 'g*')
scatter(axes_h(cur_axes), out_t.s, out_t.f, 200, 'b^')
viewCurrentPlot(axes_h(cur_axes), "Convexity", [], 0)
cur_axes = 4;
cur_fig = 4;
scatter(axes_h(cur_axes), problem.noise, out_t.s, 100, 'r*');
viewCurrentPlot(axes_h(cur_axes), "Optimum vs Noise", [], 0)
data_t.res_t = res_t;
data_t.out_t = out_t;
if isfield(data_t, 'gt_T')
cur_axes = 5;
cur_fig = 5;
num_search = size(res_t, 2);
if 1
s_list = [];
d_rotation = [];
d_translation = [];
for i = 1 : num_search
if isempty(res_t(i).s)
continue
end
d_rotation = [d_rotation, ...
norm(Log_SO3(res_t(i).H.R / data_t.gt_T.H.R))];
d_translation = [d_translation, ...
norm(res_t(i).H.t - data_t.gt_T.H.t)];
s_list = [s_list, res_t(i).s];
end
scatter3(axes_h(cur_axes), ...
s_list, d_rotation, d_translation, 100, 'r*');
xlabel(axes_h(cur_axes), "s")
ylabel(axes_h(cur_axes), "d\_rotation")
zlabel(axes_h(cur_axes), "d\_translation")
else
end
end
else
cur_axes = 1;
opts.plotting.model = 0;
opts.plotting.corrected_source = 0;
opts.plotting.corrected2target = 0;
opts.plotting.source2target = 1;
opts.plotting.source_points = 1;
plotCorrespondences(opts, axes_h, cur_axes, ...
[], data_t.correspondences, data_t.H, [], "initial")
if isfield(out_t, 's')
title_txt = "Optimization cost and scaling is " ...
+ "(" + num2str(abs(data_t.f)) ...
+ ", " + num2str(out_t.s) + ")";
else
title_txt = "Optimization cost is " ...
+ num2str(abs(data_t.f));
end
cur_axes = 2;
opts.plotting.model = 0;
opts.plotting.corrected_source = 1;
opts.plotting.corrected2target = 1;
opts.plotting.source2target = 0;
opts.plotting.source_points = 0;
plotCorrespondences(opts, axes_h, cur_axes, ...
[], data_t.correspondences, data_t.H, [], title_txt)
% data.gt_T.T
% data.H.sim
% fprintf("Noise level: %.2f\n", problem.noise)
% fprintf("Geodestic: %.3f\n", geo_dis)
end
end