Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -310,12 +310,12 @@ def process_video(video_path, process_seconds=20, conf_threshold=0.2, max_det=8)
|
|
310 |
for i in range(0, len(filtered_points), frame_interval):
|
311 |
current_points = filtered_points[:i+1]
|
312 |
|
313 |
-
# 轨迹动画帧
|
314 |
frame_trajectory = base_trajectory.copy()
|
315 |
if len(current_points) > 1:
|
316 |
points = np.array(current_points, dtype=np.int32)
|
317 |
for j in range(len(points) - 1):
|
318 |
-
ratio = j / (len(
|
319 |
color = (
|
320 |
int((1 - ratio) * 255), # B
|
321 |
50, # G
|
@@ -327,7 +327,7 @@ def process_video(video_path, process_seconds=20, conf_threshold=0.2, max_det=8)
|
|
327 |
cv2.circle(frame_trajectory, tuple(points[-1]), 8, (0, 0, 255), -1)
|
328 |
trajectory_frames.append(frame_trajectory)
|
329 |
|
330 |
-
# 热图动画帧
|
331 |
frame_heatmap = base_heatmap.copy()
|
332 |
for x, y in current_points:
|
333 |
if 0 <= x < width and 0 <= y < height:
|
@@ -339,6 +339,7 @@ def process_video(video_path, process_seconds=20, conf_threshold=0.2, max_det=8)
|
|
339 |
if np.max(frame_heatmap) > 0:
|
340 |
frame_heatmap_norm = cv2.normalize(frame_heatmap, None, 0, 255, cv2.NORM_MINMAX)
|
341 |
frame_heatmap_color = cv2.applyColorMap(frame_heatmap_norm.astype(np.uint8), cv2.COLORMAP_JET)
|
|
|
342 |
frame_heatmap_color = cv2.addWeighted(frame_heatmap_color, 0.7, np.full_like(frame_heatmap_color, 255), 0.3, 0)
|
343 |
heatmap_frames.append(frame_heatmap_color)
|
344 |
|
|
|
310 |
for i in range(0, len(filtered_points), frame_interval):
|
311 |
current_points = filtered_points[:i+1]
|
312 |
|
313 |
+
# 轨迹动画帧 - 修改颜色方案,与静态图保持一致
|
314 |
frame_trajectory = base_trajectory.copy()
|
315 |
if len(current_points) > 1:
|
316 |
points = np.array(current_points, dtype=np.int32)
|
317 |
for j in range(len(points) - 1):
|
318 |
+
ratio = j / (len(current_points) - 1) # 修改这里,使用当前总长度
|
319 |
color = (
|
320 |
int((1 - ratio) * 255), # B
|
321 |
50, # G
|
|
|
327 |
cv2.circle(frame_trajectory, tuple(points[-1]), 8, (0, 0, 255), -1)
|
328 |
trajectory_frames.append(frame_trajectory)
|
329 |
|
330 |
+
# 热图动画帧 - 修改颜色方案,使用与静态图相同的配色
|
331 |
frame_heatmap = base_heatmap.copy()
|
332 |
for x, y in current_points:
|
333 |
if 0 <= x < width and 0 <= y < height:
|
|
|
339 |
if np.max(frame_heatmap) > 0:
|
340 |
frame_heatmap_norm = cv2.normalize(frame_heatmap, None, 0, 255, cv2.NORM_MINMAX)
|
341 |
frame_heatmap_color = cv2.applyColorMap(frame_heatmap_norm.astype(np.uint8), cv2.COLORMAP_JET)
|
342 |
+
# 添加白色背景,与静态图保持一致
|
343 |
frame_heatmap_color = cv2.addWeighted(frame_heatmap_color, 0.7, np.full_like(frame_heatmap_color, 255), 0.3, 0)
|
344 |
heatmap_frames.append(frame_heatmap_color)
|
345 |
|