-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualise_cocohand.py
executable file
·36 lines (30 loc) · 1.24 KB
/
visualise_cocohand.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
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from PIL import Image
from collections import defaultdict
image = "VOC2007_37.jpg"
# image = "000000000308.jpg"
im = Image.open('/media/sander/Elements/datasets/processed_data/mittel_zisserman/images/' + image)
annotations = []
with open('/media/sander/Elements/experiments/experiment_2/test_results_mittel/trident/0/VOC2007_37.txt') as f:
for line in f:
data = line.split(" ")
print(data)
#xmin xmax ymin ymax
if float(data[1]) >= 0.50:
print("groter")
annotations.append([data[2], data[3], data[4], data[5], data[1]])
# # Create figure and axes
fig, ax = plt.subplots()
# # Display the image
ax.imshow(im)
print(annotations)
for hand in annotations:
# Create a Rectangle patch
rect = patches.Rectangle((float(hand[0]), float(hand[1])), float(hand[2]), float(hand[3]), linewidth=1, edgecolor='b', facecolor='none')
# Add the patch to the Axes
ax.add_patch(rect)
ax.annotate("Conf: " + hand[4][0:4], (float(hand[0]), float(hand[1])), color='w', weight='bold',
fontsize=6, ha='center', va='center')
plt.axis('off')
plt.savefig("/home/sander/mittal_trident.png", bbox_inches='tight')