forked from cvg/glue-factory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getLines.py
713 lines (612 loc) · 30.3 KB
/
getLines.py
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
import os
import ast
precisionTable = False
AUCTable = True
myModels = True
# import scienceplots
if myModels:
# path = "/homes/tp4618/Documents/bitbucket/SuperGlueThesis/external/glue-factory/evaluations/"
path = "/homes/tp4618/Documents/bitbucket/SuperGlueThesis/external/glue-factory/world2camEvaluations/"
else:
# path = "/homes/tp4618/Documents/bitbucket/SuperGlueThesis/external/glue-factory/pretrainedEvaluations/"
path = "/homes/tp4618/Documents/bitbucket/SuperGlueThesis/external/glue-factory/world2campretrainedEvaluations/"
folders = os.listdir(path)
print(folders)
files = []
auc_key = 'AUC_rel_pose_error_0.5'
# auc_key = 'AUC_mean_r_pose_error_0.5'
# auc_key = 'AUC_mean_t_pose_error_0.5'
# expName = 'treeEval1_poselib.txt'
# expName = 'finnEval_poselib.txt'
# expName = 'finnEval_2048-poselib.txt'
expName = 'treeEval1_2048-poselib.txt'
for folder in folders:
try:
for file in os.listdir(path + folder):
if file == expName:
files.append(f"{folder}/{file}")
except:
pass
fullPaths = [path + file for file in files]
print(fullPaths)
search_lines = ['mepi_prec@1e-4', 'mepi_prec@5e-4', 'mepi_prec@1e-3', 'mepi_prec@5e-3', 'mepi_prec@1e-2', 'mransac_inl%']
search_lines = ['AUC_rel_pose_error_0.5', 'AUC_mean_r_pose_error_0.5', 'AUC_mean_t_pose_error_0.5', 'z-time']
if precisionTable:
search_lines = ['mepi_prec@1e-4', 'mepi_prec@5e-4', 'mepi_prec@1e-3', 'mepi_prec@5e-3', 'mepi_prec@1e-2', 'mransac_inl%']
if AUCTable:
search_lines = ['AUC_rel_pose_error_0.5', 'AUC_mean_r_pose_error_0.5', 'AUC_mean_t_pose_error_0.5', 'z-time','mnum_matches', 'mnum_keypoints']
# search_lines = ['z-time', 'z-num_samples']
import matplotlib.pyplot as plt
import os
import datetime
def plot_and_save_precision(table_data, expName):
"""
Plots precision data from a table, saves the plot, and prints the save path.
Args:
table_data: A list of lists containing the plot data.
Each inner list is expected to have the format:
[model_name, mode, precision_string, overall_precision]
expName: A string representing the experiment name to be included in the filename.
"""
# Precision thresholds for the x-axis
precision_thresholds = ['1e-4', '5e-4', '1e-3', '5e-3', '1e-2']
# Create the plot
plt.figure(figsize=(10, 6)) # Adjust figure size as needed
# plt.style.use(['science','ieee'])
skippingMatchers = ["NA"] # ["nearest"]
skippingExtractors = ["NA"] # ["sift"]
filtered_table = []
print("table data before filterint", table_data)
for row in table_data:
model_name, mode, precision_string, overall_precision = row
if mode in skippingMatchers or model_name in skippingExtractors:
continue
filtered_table.append(row)
print("\n\n")
print(filtered_table)
print("\n\n")
for row in filtered_table:
model_name, mode, precision_string, overall_precision = row
precision_values = [float(x) for x in precision_string.split('/')]
# if mode in skippingMatchers or model_name in skippingExtractors:
# continue
# Shorten model and mode names for the legend
short_model_name = model_name.replace("Super", "S").replace("Glue", "G-").replace("Light", "L").replace("Point", "P-")
short_mode = mode.replace("rgb", "RGB").replace("stereo", "stereo").replace("gray", "gray").replace("epipolar", "epipolar").replace("homog", "homog").replace("depth", "D").replace("/treeEval1", "")
legend_label = f"{short_model_name}-{short_mode}"
plt.plot(precision_thresholds, precision_values, marker='o', label=legend_label)
# Add plot labels and title
if expName == 'treeEval1_poselib.txt':
dataMode = "Synthetic Data"
else:
dataMode = "Real Data"
if myModels:
pretrained = "Finetuned"
else:
pretrained = "Pretrained"
# plt.style.use('science') # Or try other styles like 'science', 'bmh', 'classic'
plt.xlabel('Precision Thresholds')
plt.ylabel('Precision')
plt.title(f'Precision of {pretrained} Models at Different Thresholds ({dataMode})')
plt.legend()
plt.grid(True)
# Create save directory if it doesn't exist
save_dir = '/homes/tp4618/Documents/bitbucket/SuperGlueThesis/external/glue-factory/EvaluationGraphs/'
os.makedirs(save_dir, exist_ok=True)
# Create filename with current datetime and expName
now = datetime.datetime.now()
filename = f'{now.strftime("%Y-%m-%d_%H-%M-%S")}_{expName}_precision_plot.png'
save_path = os.path.join(save_dir, filename)
# Save the plot
plt.savefig(save_path)
# Print the save path
print(f"Plot saved to: {save_path}")
import matplotlib.pyplot as plt
import os
import datetime
import numpy as np
def plot_and_save_auc_bar_chart(table_data, expName, auc_key):
"""
Plots a bar chart of AUC data from a table, saves the plot, and prints the save path.
Args:
table_data: A list of lists containing the plot data.
Each inner list is expected to have the format:
[model_name, mode, auc_rel_pose_error_0.5_string,
auc_mean_r_pose_error_0.5_string,
auc_mean_t_pose_error_0.5_string, z_time]
expName: A string representing the experiment name to be included in the filename.
auc_key: The key to select the AUC data to plot
('AUC_rel_pose_error_0.5', 'AUC_mean_r_pose_error_0.5', or 'AUC_mean_t_pose_error_0.5')
"""
print(table_data)
# Degrees for the x-axis
degrees = [1, 2.5, 5, 7.5, 10, 15, 20]
# Get the index of the AUC key in the data
auc_key_index = {
'AUC_rel_pose_error_0.5': 0,
'AUC_mean_t_pose_error_0.5': 1,
'AUC_mean_r_pose_error_0.5': 2,
}[auc_key]
# [['aliked', 'lightglue', '0.0006/0.0026/0.0075/0.0152/0.0242/0.0416/0.0584', '0.6240/0.8251/0.9116/0.9411/0.9558/0.9705/0.9779', '0.0006/0.0026/0.0075/0.0152/0.0242/0.0416/0.0584', 'N/A'],
# Create the plot
plt.figure(figsize=(10, 6)) # Adjust figure size as needed
# Group data by model type (LightGlue or SuperGlue)
lightglue_data = []
superglue_data = []
for row in table_data:
model_name, mode, keypoints, matches, *auc_data, _ = row
# print(auc_key_index)
# auc_values = [float(x) for x in auc_data.split('/')]
auc_values = [float(x) for x in auc_data[auc_key_index].split('/')]
# print(auc_values)
# exit()
# Shorten model and mode names for the legend
short_model_name = model_name.replace("Super", "S").replace("Glue", "G-").replace("Light", "L").replace("Point", "P-")
short_mode = mode.replace("rgb", "RGB").replace("stereo", "stereo").replace("gray", "gray").replace("epipolar", "epipolar").replace("homog", "homog").replace("depth", "D")
legend_label = f"{short_model_name}-{short_mode}"
# print(f"model name is {model_name}")
# print(model_name, mode)
if "LightGlue" in mode:
print(mode, "\n\n\n\n\n\n\n")
lightglue_data.append((legend_label, auc_values))
else:
superglue_data.append((legend_label, auc_values))
# Set up bar positions for side-by-side plotting
bar_width = 0.35
index = np.arange(len(degrees))
# Use a predefined color palette and theme
# print(plt.style.available)
# Use different styles for LightGlue and SuperGlue
# lightglue_style = 'seaborn-v0_8-colorblind'
# superglue_style = 'tableau-colorblind10'
# Use Seaborn color palettes for LightGlue and SuperGlue
import seaborn as sns
lightglue_palette = sns.color_palette("crest", n_colors=len(lightglue_data)) # Green-ish mix
superglue_palette = sns.color_palette("flare", n_colors=len(superglue_data)) # Orange-ish mix
stacked = False
usingBlackLines = True
if stacked:
bottom = np.zeros(len(degrees))
for i, (label, values) in enumerate(lightglue_data):
plt.bar(index, values, bar_width, bottom=bottom, label=label, color=lightglue_palette[i])
bottom += values
# Plot SuperGlue models stacked with colors from the palette
bottom = np.zeros(len(degrees))
for i, (label, values) in enumerate(superglue_data):
plt.bar(index + bar_width, values, bar_width, bottom=bottom, label=label, color=superglue_palette[i])
bottom += values
else:
# Sort LightGlue and SuperGlue data separately based on the sum of AUC values
print(lightglue_data)
print(superglue_data)
lightglue_data.sort(key=lambda x: sum(x[1]), reverse=True) # Ascending order for LightGlue (lower values first)
superglue_data.sort(key=lambda x: sum(x[1]), reverse=True)
# Plot LightGlue models
for i, (label, values) in enumerate(lightglue_data):
bars = plt.bar(index, values, bar_width, label=label, color=lightglue_palette[i])
if usingBlackLines:
for bar in bars:
# Get the x-coordinates of the bar's edges
x_min, x_max = bar.get_x(), bar.get_x() + bar.get_width()
# Draw a black line only at the top of the bar, within its boundaries
plt.hlines(bar.get_height(), x_min, x_max, colors='black', linewidth=1)
# Plot SuperGlue models
for i, (label, values) in enumerate(superglue_data):
bars = plt.bar(index + bar_width, values, bar_width, label=label, color=superglue_palette[i])
if usingBlackLines:
for bar in bars:
# Get the x-coordinates of the bar's edges
x_min, x_max = bar.get_x(), bar.get_x() + bar.get_width()
# Draw a black line only at the top of the bar, within its boundaries
plt.hlines(bar.get_height(), x_min, x_max, colors='black', linewidth=1)
# Plot bars with overlay effect and black lines at the top of each bar
# # Plot LightGlue models
# for i, (label, values) in enumerate(lightglue_data):
# plt.bar(index, values, bar_width, label=label, color=lightglue_palette[i])
# # Plot SuperGlue models
# for i, (label, values) in enumerate(superglue_data):
# plt.bar(index + bar_width, values, bar_width, label=label, color=superglue_palette[i])
# # Plot LightGlue models stacked with its style
# with plt.style.context(lightglue_style):
# bottom = np.zeros(len(degrees))
# for label, values in lightglue_data:
# plt.bar(index, values, bar_width, bottom=bottom, label=label)
# bottom += values
# # Plot SuperGlue models stacked with its style
# with plt.style.context(superglue_style):
# bottom = np.zeros(len(degrees))
# for label, values in superglue_data:
# plt.bar(index + bar_width, values, bar_width, bottom=bottom, label=label)
# bottom += values
# Add plot labels and title
plt.xlabel('Degrees')
plt.ylabel(auc_key)
plt.title(f'{auc_key} at Different Degrees ({expName})')
plt.xticks(index + bar_width / 2, degrees) # Set x-ticks to be in the middle of the grouped bars
plt.legend()
plt.grid(True)
# # Plot LightGlue models stacked
# bottom = [0] * len(degrees)
# for label, values in lightglue_data:
# plt.bar(degrees, values, bottom=bottom, label=label)
# bottom = [bottom[i] + values[i] for i in range(len(degrees))]
# # Plot SuperGlue models stacked on top of LightGlue
# bottom = [0] * len(degrees)
# for label, values in superglue_data:
# plt.bar(degrees, values, bottom=bottom, label=label)
# bottom = [bottom[i] + values[i] for i in range(len(degrees))]
# # Add plot labels and title
# plt.xlabel('Degrees')
# plt.ylabel(auc_key)
# plt.title(f'{auc_key} at Different Degrees ({expName})')
# plt.legend()
# plt.grid(True)
# Create save directory if it doesn't exist
save_dir = '/homes/tp4618/Documents/bitbucket/SuperGlueThesis/external/glue-factory/EvaluationGraphs/'
os.makedirs(save_dir, exist_ok=True)
# Create filename with current datetime and expName
now = datetime.datetime.now()
# filename = f'{now.strftime("%Y-%m-%d_%H-%M-%S")}_{expName}_AUC_figure.png'
filename = f'{expName}_AUC_figure.png'
save_path = os.path.join(save_dir, filename)
# Save the plot
plt.savefig(save_path)
# Print the save path
print(f"Plot saved to: {save_path}")
# result_dict = {}
# for file in fullPaths:
# with open(file, 'r') as f:
# for line in f:
# # print(line)
# for search_term in search_lines:
# if search_term in line:
# key = os.path.join(*file.split('/')[-2:]) # Get the last two folders as the key
# if key not in result_dict:
# result_dict[key] = []
# # print(line.strip())
# result_dict[key].append(line.strip())
result_dict = {}
for file in fullPaths:
with open(file, 'r') as f:
for line in f:
for search_term in search_lines:
if search_term in line:
key = os.path.join(*file.split('/')[-2:])
if key not in result_dict:
result_dict[key] = {} # Initialize as a dictionary
# Split the line based on ':'
metric_name, value_str = line.strip().split(':')
# Convert the value to a float and round to 4 decimal places
try:
value = round(float(value_str.strip()), 4)
except:
values_list = ast.literal_eval(value_str.strip())
value = [round(float(val), 4) for val in values_list]
# value = value_str
# Store in the dictionary
result_dict[key][metric_name.strip()] = value
print("results dict is", result_dict)
if myModels:
searches = ["19-08", "20-08"] #]
else:
searches = ["point+light", "point+super"]
searches = [""]
# usingNot = True
for k, v in result_dict.items():
for search in searches:
if search in k:
# print(k)
print(k.split('/')[0], v)
continue
# if "13-08" in k or "point+light" in k or "point+super" in k:
# for k, v in result_dict.items():
# k = k.split('/')[0]
# print(k, v["mnum_keypoints"], v["mnum_matches"])
# exit()
# renameDict = {
# "20-08-lightglue-depth-8-gray-nopretrain-clip": "Lightglue gray",
# "20-08-actuallylight-depth-8-RGB-nopretrain-clip": "Lightglue RGB",
# "20-08-actuallylight-depth-8-RGBDEPTH-nopretrain-clip": "Lightglue rgbd",
# "20-08-lightglue-depth-8-stereo-nopretrain-clip": "Lightglue stereo",
# "20-08-lightglue-depth-8-gray-HOMOG_RANDOM-clip": "Lightglue scratch",
# "19-08-lightglue-noNeg-adj1-8-nopretrain": "Lightglue (no clip)",
# "19-08-lightglue-noNeg-adj1-8-nopretrain-epipolar-clipgrad": "Lightglue epipolar",
# "19-08-superglue-noNeg-adj1-8-nopretrain": "Superglue gray",
# "20-08-lightglue-depth-8-RGB-nopretrain-clip": "Superglue rgb",
# "20-08-lightglue-depth-8-RGBDEPTH-nopretrain-clip": "SuperGlue RGBD",
# "20-08-superglue-8-stereo-clip": "Superglue stereo",
# }
renameDict = {
f'20-08-lightglue-depth-8-gray-nopretrain-clip/{expName}': "LightGlue Gray",
f'20-08-lightglue-depth-8-stereo-nopretrain-clip/{expName}': "LightGlue Sstereo",
f'19-08-superglue-noNeg-adj1-8-nopretrain/{expName}': "SuperGlue Gray",
f'20-08-lightglue-depth-8-gray-HOMOG_RANDOM-clip/{expName}': "LightGlue Scratch",
f'20-08-lightglue-depth-8-RGB-nopretrain-clip/{expName}': "SuperGlue RGB",
f'20-08-actuallylight-depth-8-RGBDEPTH-nopretrain-clip/{expName}': "LightGlue RGBD",
f'19-08-lightglue-noNeg-adj1-8-nopretrain/{expName}': "LightGlue (no clip)",
f'19-08-lightglue-noNeg-adj1-8-nopretrain-epipolar-clipgrad/{expName}': "LightGlue Epipolar",
f'20-08-lightglue-depth-8-RGBDEPTH-nopretrain-clip/{expName}': "SuperGlue RGBD",
f'20-08-actuallylight-depth-8-RGB-nopretrain-clip/{expName}': "LightGlue RGB",
}
def rename_matcher(matcher):
# matcher = matcher.lower() # Convert to lowercase for easier matching
try:
# print("original matcher is", matcher)
# matcher += f"{expName.split('-')[0]}\_poselib.txt"
# matcher = matcher.split('/')[0]
print("matcher key is", matcher)
base_name = renameDict[matcher] #, matcher) # Use the dictionary to rename matchers
print("old name is", matcher, "new name is", base_name)
except:
if "light" in matcher:
base_name = "LightGlue"
else:
base_name = "SuperGlue"
# else:
# return matcher # Return unchanged if neither is found
# descriptors = ["stereo", "rgbdepth", "rgb", "gray", "epipolar", "homog"]
# for desc in descriptors:
# if desc in matcher:
# return base_name + "-" + desc
# print(base_name, matcher)
# print("\n\n\n\n\n")
return base_name # Return base name if no descriptor is found
def matcher_sort_key(row):
matcher = row[1].lower() # Extract matcher name and convert to lowercase
if "lightglue" in matcher:
base_order = 0
elif "superglue" in matcher:
base_order = 1
else:
base_order = 2 # Place any other matchers at the end
descriptors = ["nothing", "epipolar", "rgb", "rgbdepth", "stereo"]
desc_order = next((i for i, desc in enumerate(descriptors) if desc in matcher), len(descriptors)) # Get descriptor order or place at the end
return (base_order, desc_order) # Return a tuple for sorting
if precisionTable:
# Process the dictionary and generate LaTeX table
table_data = []
for k, v in result_dict.items():
for search in searches:
if search in k:
if not myModels:
extractor, matcher = k.split('+')
matcher = matcher.split('_')[0]
print(extractor, matcher)
else:
# print(k)
# if k == "20-08-lightglue-depth-8-RGB-nopretrain-clip/treeEval1_poselib.txt":
# print("replacing lightglue")
# k = "20-08-superglue-depth-8-RGB-nopretrain-clip"
# if k == "20-08-lightglue-depth-8-RGBDEPTH-nopretrain-clip/treeEval1_poselib.txt":
# print("replacing lightglue")
# k = "20-08-superglue-depth-8-RGBDEPTH-nopretrain-clip"
# if k == "20-08-lightglue-depth-8-RGB-nopretrain-clip/finnEval_poselib.txt":
# print("replacing lightglue")
# k = "20-08-superglue-depth-8-RGB-nopretrain-clip"
# if k == "20-08-lightglue-depth-8-RGBDEPTH-nopretrain-clip/finnEval_poselib.txt":
# print("replacing lightglue")
# k = "20-08-superglue-depth-8-RGBDEPTH-nopretrain-clip"
extractor = "SuperPoint"
# matcher = "LightGlue" + str(k)
matcher = rename_matcher(k)
# matcher = k
mepi_values = "/".join([f"{v[key]:.4f}" for key in v.keys() if 'mepi_prec' in key])
ransac_value = f"{v['mransac_inl%']:.4f}"
table_data.append([extractor, matcher, mepi_values, ransac_value])
# table_data = sorted(table_data, key=matcher_sort_key)
plot_and_save_precision(table_data, expName)
print("\n\n",table_data,"\n\n")
# exit()
# Create the LaTeX table string (same as before)#
makeLatex = True
if makeLatex:
latex_table = r"""
\begin{table}[ht]
\centering
\footnotesize
\caption{mEpi Precision and RANSAC Inlier Percentage for Different Methods}
\label{tab:results}
\setlength\tabcolsep{3pt}
\begin{tabular}{ll>{\centering\arraybackslash}p{5cm}c}
\toprule
\multicolumn{1}{c}{\textbf{Extractor}} & \multicolumn{1}{c}{\textbf{Matcher}} & \multicolumn{1}{c}{\textbf{1e-4/5e-4/1e-3/5e-3/1e-2}} & \textbf{RANSAC Inlier \%} \\
\midrule
"""
for row in table_data:
latex_table += " & ".join(row) + r" \\" + "\n"
latex_table += r"""
\bottomrule
\end{tabular}
\end{table}
"""
# Print the LaTeX table
print(latex_table)
if AUCTable:
# Process the dictionary and generate LaTeX table
table_data = []
for k, v in result_dict.items():
for search in searches:
if search in k:
# print(search, k)
# print(v.)
if not myModels:
extractor, matcher = k.split('+')
matcher = matcher.split('_')[0]
else:
# print(k)
# extractor = "SuperPoint"
# matcher = "LightGlue" + str(k)
print(k)
# if k == "20-08-lightglue-depth-8-RGB-nopretrain-clip/treeEval1_poselib.txt":
# k = "20-08-superglue-depth-8-RGB-nopretrain-clip"
# if k == "20-08-lightglue-depth-8-RGBDEPTH-nopretrain-clip/treeEval1_poselib.txt":
# k = "20-08-superglue-depth-8-RGBDEPTH-nopretrain-clip"
# if k == "20-08-lightglue-depth-8-RGB-nopretrain-clip/finnEval_poselib.txt":
# print("replacing lightglue")
# k = "20-08-superglue-depth-8-RGB-nopretrain-clip"
# if k == "20-08-lightglue-depth-8-RGBDEPTH-nopretrain-clip/finnEval_poselib.txt":
# print("replacing lightglue")
# k = "20-08-superglue-depth-8-RGBDEPTH-nopretrain-clip"
extractor = "SuperPoint"
# matcher = "LightGlue" + str(k)
matcher = rename_matcher(k) #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
print("called rename matcher")
# matcher = k
# extractor = extractor.replace("_", "\_").replace("/", "")# for latex formatting
# matcher = matcher.replace("_", "\_").replace("/", "")# for latex formatting
# # print("\n\n")
# # print(v[k])
# print(extractor, matcher)
# Extract and format AUC values (handling lists)
auc_rel_pose = "/".join([f"{float(val):.4f}" for val in v['AUC_rel_pose_error_0.5']])
auc_trans = "/".join([f"{float(val):.4f}" for val in v['AUC_mean_t_pose_error_0.5']])
auc_rot = "/".join([f"{float(val):.4f}" for val in v['AUC_mean_r_pose_error_0.5']])
keypoints = v["mnum_keypoints"]
matches = v["mnum_matches"]
# v["mnum_keypoints"], v["mnum_matches"]
# Extract and format time (handling potential list or single value)
time_values = v.get('z-time') # Use .get() to avoid KeyError if 'z-time' is missing
if time_values:
if isinstance(time_values, list):
time_ms = "/".join([f"{float(val):.4f}" for val in time_values])
else:
time_ms = f"{float(time_values):.4f}"
else:
time_ms = "N/A"
table_data = sorted(table_data, key=matcher_sort_key)
table_data.append([extractor, matcher, keypoints, matches, auc_rel_pose, auc_trans, auc_rot, time_ms])
# Create the LaTeX table string
plot_and_save_auc_bar_chart(table_data, expName, auc_key)
latex_table = r"""
\begin{table}[ht]
\centering
\footnotesize
\caption{AUC for different methods}
\label{tab:auc_results}
\setlength\tabcolsep{3pt}
% Define boolean variables for conditional inclusion
\newboolean{showRelativeError}
\newboolean{showTranslationalError}
\newboolean{showRotationalError}
\newboolean{showTiming} % New boolean for timing
% Set the values of the boolean variables (true or false)
\setboolean{showRelativeError}{true} % Show Relative Error
\setboolean{showTranslationalError}{false} % Hide Translational Error # Changed to true to match your output
\setboolean{showRotationalError}{false} % Hide Rotational Error
\setboolean{showTiming}{true} % Show Timing
% \begin{tabular}{l>{\centering\arraybackslash}m{2cm}cccc}
% \begin{tabular}{l>{\centering\arraybackslash}m{2cm}cccccc}
% \toprule
% \multicolumn{2}{c}{\textbf{Extractor Matcher}} &
% \multicolumn{4}{c}{\textbf{Extractor Matcher KeyPoints Matches}} &
% \ifthenelse{\boolean{showRelativeError}}{\textbf{Relative Error}}{} &
% \ifthenelse{\boolean{showTranslationalError}}{\textbf{Translational Error}}{} &
% \ifthenelse{\boolean{showRotationalError}}{\textbf{Rotational Error}}{} &
% \ifthenelse{\boolean{showTiming}}{\textbf{Time /ms}}{} \\
\begin{tabular}{l>{\centering\arraybackslash}m{2cm}cccccc}
\toprule
% \multicolumn{4}{c}{\textbf{Extractor Matcher KeyPoints Matches}} &
\multirow{2}{*}{\textbf{Extractor}} & \multirow{2}{*}{\textbf{Matcher}} & \multirow{2}{*}{\textbf{KeyPoints}} & \multirow{2}{*}{\textbf{Matches}} &
\ifthenelse{\boolean{showRelativeError}}{\multicolumn{1}{c}{\textbf{LO-RANSAC AUC}}}{} &
\ifthenelse{\boolean{showTranslationalError}}{\textbf{Translational Error}}{} &
\ifthenelse{\boolean{showRotationalError}}{\textbf{Rotational Error}}{} &
\ifthenelse{\boolean{showTiming}}{\textbf{Time /ms}}{} \\
\cmidrule(lr){5-5}
& & & & \multicolumn{1}{c}{\textbf{5°/10°/20°}} \\
\midrule
"""
# \multicolumn{2}{c}{\textbf{Extractor Matcher}} & \ifthenelse{\boolean{showRelativeError}}{\multicolumn{1}{>{\centering\arraybackslash}m{3.5cm}}{\textbf{Relative Error}}}{}& \ifthenelse{\boolean{showTranslationalError}}{\multicolumn{1}{>{\centering\arraybackslash}m{3.5cm}}{\textbf{Translational Error}}}{}& \ifthenelse{\boolean{showRotationalError}}{\multicolumn{1}{>{\centering\arraybackslash}m{3.5cm}}{\textbf{Rotational Error}}}{}& \ifthenelse{\boolean{showTiming}}{\multicolumn{1}{c}{\textbf{Time /ms}}}{} \\
for row in table_data:
extractor, matcher, keypoints, matches, auc_rel_pose, auc_trans, auc_rot, time_ms = row
latex_table += f"{extractor} & {matcher} & {keypoints} & {matches} "
latex_table += f"& \\ifthenelse{{\\boolean{{showRelativeError}}}}{{{auc_rel_pose}}}{{}} "
latex_table += f"& \\ifthenelse{{\\boolean{{showTranslationalError}}}}{{{auc_trans}}}{{}} "
latex_table += f"& \\ifthenelse{{\\boolean{{showRotationalError}}}}{{{auc_rot}}}{{}} "
latex_table += f"& \\ifthenelse{{\\boolean{{showTiming}}}}{{{time_ms}}}{{}} \\\\" + "\n"
latex_table += r"""
\bottomrule
\end{tabular}
\end{table}
"""
# Print the LaTeX table
print(latex_table)
# for k, v in result_dict.items():
# for search in searches:
# if search in k:
# print(k.split('/')[0], v)
# # print(k)
# print(k, v)
print("this was ", expName)
"""
mepi_prec@1e-4: 0.026000000536441803
mepi_prec@5e-4: 0.12300000339746475
mepi_prec@1e-3: 0.23199999332427979
mepi_prec@5e-3: 0.7129999995231628
mepi_prec@1e-2: 0.8600000143051147
mnum_matches: 1225.442
mnum_keypoints: 2048.0
mAA_rel_pose_error_0.5: 0.6217142857142858
mAA_rel_pose_error_1.0: 0.6760857142857143
mAA_rel_pose_error_1.5: 0.6784999999999999
best_threshold_rel_pose_error: 1.5
rel_pose_error@1°: 0.348
[email protected]°: 0.5782
rel_pose_error@5°: 0.6959
[email protected]°: 0.7434
rel_pose_error@10°: 0.7695
rel_pose_error@15°: 0.7988
rel_pose_error@20°: 0.8157
rel_pose_error_mAA: 0.6784999999999999
mrel_pose_error: 0.697
mmean_t_pose_error: 0.048
mmean_r_pose_error: 0.697
mstd_t_pose_error: 0.0
mstd_r_pose_error: 0.0
mransac_inl: 954.0
mransac_inl%: 0.7730000019073486
mAA_mean_t_pose_error_0.5: 0.9685714285714286
mAA_mean_t_pose_error_1.0: 0.9749428571428572
mAA_mean_t_pose_error_1.5: 0.9738714285714286
best_threshold_mean_t_pose_error: 1.0
mean_t_pose_error@1°: 0.9118
[email protected]°: 0.9633
mean_t_pose_error@5°: 0.9816
[email protected]°: 0.9878
mean_t_pose_error@10°: 0.9908
mean_t_pose_error@15°: 0.9939
mean_t_pose_error@20°: 0.9954
mean_t_pose_error_mAA: 0.9749428571428572
mAA_mean_r_pose_error_0.5: 0.6217714285714286
mAA_mean_r_pose_error_1.0: 0.676142857142857
mAA_mean_r_pose_error_1.5: 0.6785428571428571
best_threshold_mean_r_pose_error: 1.5
mean_r_pose_error@1°: 0.3482
[email protected]°: 0.5783
mean_r_pose_error@5°: 0.6959
[email protected]°: 0.7434
mean_r_pose_error@10°: 0.7695
mean_r_pose_error@15°: 0.7988
mean_r_pose_error@20°: 0.8157
mean_r_pose_error_mAA: 0.6785428571428571
AUC_rel_pose_error_0.5: [0.2269, 0.4689, 0.6305, 0.6997, 0.7385, 0.7816, 0.8059]
threshold_rel_pose_error_0.5: ['1', '2.5', '5', '7.5', '10', '15', '20']
AUC_rel_pose_error_1.0: [0.3307, 0.5681, 0.694, 0.7443, 0.772, 0.8027, 0.8208]
threshold_rel_pose_error_1.0: ['1', '2.5', '5', '7.5', '10', '15', '20']
AUC_rel_pose_error_1.5: [0.348, 0.5782, 0.6959, 0.7434, 0.7695, 0.7988, 0.8157]
threshold_rel_pose_error_1.5: ['1', '2.5', '5', '7.5', '10', '15', '20']
AUC_mean_t_pose_error_0.5: [0.8884, 0.9543, 0.9772, 0.9848, 0.9886, 0.9924, 0.9943]
threshold_mean_t_pose_error_0.5: ['1', '2.5', '5', '7.5', '10', '15', '20']
AUC_mean_t_pose_error_1.0: [0.9118, 0.9633, 0.9816, 0.9878, 0.9908, 0.9939, 0.9954]
threshold_mean_t_pose_error_1.0: ['1', '2.5', '5', '7.5', '10', '15', '20']
AUC_mean_t_pose_error_1.5: [0.9105, 0.9607, 0.9803, 0.9869, 0.9902, 0.9934, 0.9951]
threshold_mean_t_pose_error_1.5: ['1', '2.5', '5', '7.5', '10', '15', '20']
AUC_mean_r_pose_error_0.5: [0.2271, 0.469, 0.6305, 0.6997, 0.7386, 0.7816, 0.8059]
threshold_mean_r_pose_error_0.5: ['1', '2.5', '5', '7.5', '10', '15', '20']
AUC_mean_r_pose_error_1.0: [0.3309, 0.5682, 0.694, 0.7443, 0.772, 0.8028, 0.8208]
threshold_mean_r_pose_error_1.0: ['1', '2.5', '5', '7.5', '10', '15', '20']
AUC_mean_r_pose_error_1.5: [0.3482, 0.5783, 0.6959, 0.7434, 0.7695, 0.7988, 0.8157]
threshold_mean_r_pose_error_1.5: ['1', '2.5', '5', '7.5', '10', '15', '20']
/homes/tp4618/Documents/bitbucket/SuperGlueThesis/external/glue-factory/pretrainedEvalFigures/superpoint+nearest_neighbor_matcher/pose_recall_treeEval1_poselib.png
z-time: 0.02428972172137486
z-num_samples: 5646.0
"""