Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -103,14 +103,22 @@ def process_video(video_path, process_seconds=20, conf_threshold=0.2, max_det=8)
|
|
103 |
for kpts in r.keypoints:
|
104 |
if isinstance(kpts, torch.Tensor):
|
105 |
kpts = kpts.cpu().numpy()
|
106 |
-
#
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
# 收集检测信息
|
116 |
frame_info = {
|
|
|
103 |
for kpts in r.keypoints:
|
104 |
if isinstance(kpts, torch.Tensor):
|
105 |
kpts = kpts.cpu().numpy()
|
106 |
+
# 打印关键点格式以便调试
|
107 |
+
# print(f"Keypoints shape: {kpts.shape}")
|
108 |
+
|
109 |
+
# 确保关键点数据是正确的格式
|
110 |
+
if isinstance(kpts, np.ndarray):
|
111 |
+
if len(kpts.shape) == 2: # [n_points, 2/3]
|
112 |
+
if kpts.shape[0] > 0: # 确保有关键点
|
113 |
+
# 使用第一个关键点
|
114 |
+
if kpts.shape[1] >= 2: # 确保有x,y坐标
|
115 |
+
x, y = kpts[0, 0], kpts[0, 1]
|
116 |
+
if isinstance(x, (int, float)) and isinstance(y, (int, float)):
|
117 |
+
x, y = int(x), int(y)
|
118 |
+
all_positions.append([x, y])
|
119 |
+
# 更新热图
|
120 |
+
if 0 <= x < width and 0 <= y < height:
|
121 |
+
heatmap[y, x] += 1
|
122 |
|
123 |
# 收集检测信息
|
124 |
frame_info = {
|