92 lines
3.3 KiB
Python
Executable File
92 lines
3.3 KiB
Python
Executable File
import h5py
|
|
import numpy as np
|
|
|
|
rmac_out_file = '/media/Data/data/beni_culturali/out/rmac_out.txt'
|
|
orb_out_file = '/media/Data/data/beni_culturali/out/orb_out.txt'
|
|
|
|
ground_truth_file = '/media/Data/data/beni_culturali/groundtruth.txt'
|
|
|
|
ground_truth = {}
|
|
rmac_out = {}
|
|
orb_out = {}
|
|
|
|
query_folder = '/media/Data/data/beni_culturali/ImmaginiComparazioni/'
|
|
img_folder = '/media/Data/data/beni_culturali/thumbs/'
|
|
|
|
with open(ground_truth_file, 'r') as f:
|
|
for line in f:
|
|
values = line.strip().split(',')
|
|
ground_truth[values[0]] = values[1:]
|
|
|
|
with open(orb_out_file, 'r') as f:
|
|
for line in f:
|
|
values = line.strip().split(',')
|
|
orb_out[values[0]] = values[1]
|
|
|
|
with open(rmac_out_file, 'r') as f:
|
|
for line in f:
|
|
values = line.strip().split(',')
|
|
rmac_out[values[0]] = values[1:]
|
|
|
|
counter = 0
|
|
found = 0
|
|
|
|
html = '<html><body>'
|
|
html += '<h1 align="center">Image Analysis Report</h1>'
|
|
html += '<h2>Numero totale query: 64 (una query è ripetuta due volte)</h2>'
|
|
html += '<h2>Immagini Recuperate (evidenziate dal bordo verde):</h2>'
|
|
html += '<ul><li><h3>Al primo risultato: <span style="color:red;">78%</span> (50 su 64)</h3></li>'
|
|
html += '<li><h3>Entro il terzo risultato: <span style="color:red;">83%</span> (53 su 64)</h3></li>'
|
|
html += '<li><h3>Entro il 60esimo risultato: <span style="color:red;">84%</span> (54 su 64)</h3></li></ul>'
|
|
|
|
html += '<h2>Elenco delle query e delle immagini recuperate:</h2>'
|
|
html += '<h3>[query, <span style="color:green;">immagine ritrovata</span>, posizione (ranking)]</h3><hr>'
|
|
|
|
counter = 1
|
|
|
|
for key, value in ground_truth.items():
|
|
orb_res = orb_out[key]
|
|
rmac_res = rmac_out[key]
|
|
#print(key)
|
|
#print(value)
|
|
# print(orb_res + '\n')
|
|
html += '<div><span style="color:red;">' + str(counter) + '. </span><b>' + key + '</b>'
|
|
tmp = ''
|
|
found_id = ''
|
|
found = False
|
|
k = 0
|
|
if orb_res in value:
|
|
found = True
|
|
found_id = orb_res
|
|
ground_truth[key] = 'already_found'
|
|
tmp += '<img style="border-width: 5px; margin-left:10px; padding:2px; border-color: #00AA00; border-style: solid;" width="128" title="' + orb_res + '" src="' + img_folder + orb_res + '">'
|
|
|
|
else:
|
|
for k in range(60):
|
|
if rmac_res[k] in value:
|
|
tmp += '<img style="border-width: 5px; margin-left:10px; padding:2px; border-color: #00AA00; border-style: solid;" width="128" title="' + rmac_res[k] + '" src="' + img_folder + rmac_res[k] + '">'
|
|
found = True
|
|
found_id = rmac_res[k]
|
|
ground_truth[key] = 'already_found'
|
|
break
|
|
if k < 2:
|
|
tmp += '<img width="128" title="' + rmac_res[k] + '" src="' + img_folder + rmac_res[k] + '">'
|
|
else:
|
|
tmp += '<span>.</span>'
|
|
|
|
if found:
|
|
html += ', <span style="color:green;">' + found_id + '</span>' + ', (ranking: <b>' + str(k + 1) + '</b>)'
|
|
else:
|
|
html += ', <span style="color:red;"> NONE</span>'
|
|
|
|
html += '</br></br><img width="128" style="padding:5px;" src="' + query_folder + key + '">'
|
|
if found:
|
|
html += tmp
|
|
else:
|
|
html += '<img style="padding:32px; margin-left:10px;" height="48" src="/media/Data/data/beni_culturali/out/notfound.png">'
|
|
|
|
html += '</br></div><hr>'
|
|
counter += 1
|
|
html += '</body></html>'
|
|
print(html)
|