Skip to content

Commit 2100d96

Browse files
committed
Updating eyepilot
1 parent 96acf1a commit 2100d96

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

app_tracker/data_stoarge.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import time
1313
import csv
1414
import cv2
15+
import re
1516
import os
1617

1718
from pathlib import Path
@@ -96,14 +97,31 @@ def make_gifs(self):
9697
plt.imshow(map_image, extent=[xmin, xmax, ymin, ymax]) # Display the screenshot as the background
9798
plt.axis('off')
9899

99-
plt.imshow(density.T, origin='lower', cmap='viridis', extent=[xmin, xmax, ymin, ymax],alpha=0.5)
100+
# get colormap
101+
ncolors = 256
102+
color_array = plt.get_cmap('hot')(range(ncolors))
103+
104+
# change alpha values
105+
color_array[:,-1] = np.linspace(1.0,0.0,ncolors)
106+
107+
# create a colormap object
108+
map_object = LinearSegmentedColormap.from_list(name='hot',colors=color_array)
109+
110+
plt.imshow(density.T, origin='lower', cmap=map_object, extent=[xmin, xmax, ymin, ymax],alpha=0.5)
100111
plt.axis('off')
101112
# Save the combined image with heatmap overlay
102-
plt.savefig(f"{self.directory_raw}/heatmap_{number}_{int(prev_timestamp)}.png", bbox_inches='tight')
113+
plt.savefig(f"{self.directory_raw}/heatmap_{number}.png", bbox_inches='tight')
103114
number+=1
104115

116+
def numerical_sort(value):
117+
parts = re.findall(r'\d+', value)
118+
return list(map(int, parts))
119+
105120
images = []
106-
for filename in glob.glob(f"{self.directory_raw}/heatmap_*.png"):
121+
file_list = glob.glob(f"{self.directory_raw}/heatmap_*.png")
122+
file_list_sorted = sorted(file_list, key=numerical_sort)
123+
for filename in file_list_sorted:
124+
print(filename)
107125
img = cv2.imread(filename)
108126
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
109127
images.append(img)

0 commit comments

Comments
 (0)