-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualizer.py
More file actions
43 lines (30 loc) · 819 Bytes
/
Copy pathvisualizer.py
File metadata and controls
43 lines (30 loc) · 819 Bytes
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
import cv2
def highlight_regions(image_path, ranked_items):
image = cv2.imread(image_path)
top_items = ranked_items[:5]
for item in top_items:
coords = item["coords"]
x1 = int(coords[0][0])
y1 = int(coords[0][1])
x2 = int(coords[2][0])
y2 = int(coords[2][1])
attention = round(item["attention"], 2)
cv2.rectangle(
image,
(x1, y1),
(x2, y2),
(0, 255, 0),
2
)
cv2.putText(
image,
f"A:{attention}",
(x1, y1 - 10),
cv2.FONT_HERSHEY_SIMPLEX,
0.5,
(0, 255, 0),
2
)
output_path = "outputs/cognitive_attention.png"
cv2.imwrite(output_path, image)
return output_path