Skip to content

Commit 6413461

Browse files
committed
filter: discard incomplete or half-body poses with low joint visibility
1 parent be634f6 commit 6413461

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

fall_core.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,22 @@ def _safe_aspect_ratio(self, p):
9898
w, h = max(x) - min(x), max(y) - min(y)
9999
return w / h if h else 0
100100

101-
def is_pose_complete(self, pose, required_joints=(10, 11, 13, 14, 22, 23, 25, 26)):
101+
def is_pose_complete(self, pose, required_joints=(11, 14, 23, 26)):
102102
try:
103+
complete = True
104+
visible_joints = 0
105+
length = len(pose) - (len(pose) % 3)
106+
107+
for i in range(0, length, 3):
108+
x, y, conf = pose[i], pose[i + 1], pose[i + 2]
109+
if conf > 0.2:
110+
visible_joints += 1
111+
103112
for idx in required_joints:
104-
x, y = pose[idx], pose[idx + 1]
105-
if x == 0 or y == 0:
106-
return False
107-
return True
113+
if pose[idx] == 0 or pose[idx + 1] == 0:
114+
complete = False
115+
116+
return complete and visible_joints >= 10
108117
except IndexError:
109118
return False
110119

@@ -170,7 +179,7 @@ def draw_debug_overlay(self, image, results):
170179

171180
def load_model(self, path):
172181
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
173-
weights = torch.load(path, map_location=device)
182+
weights = torch.load(path, map_location=device, weights_only=False)
174183
model = weights["model"].float().eval()
175184
return (model.half().to(device) if torch.cuda.is_available() else model), device
176185

realtime.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import cv2
22
import time
3-
from fall_detector_multi import FallDetectorMulti
3+
from fall_core import FallDetectorMulti
44
from config import FPS, WINDOW_SIZE, V_THRESH, DY_THRESH, ASPECT_RATIO_THRESH
55

66

@@ -20,7 +20,6 @@ def process_realtime_camera():
2020
if not ret:
2121
break
2222

23-
# ✅ 改成使用 core.py 的 handle_frame()
2423
_image, prev_time = detector.handle_frame(frame, prev_time)
2524

2625
cv2.imshow("Real-Time Fall Detection", _image)

video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def process_video():
88
videos_path = "fall_dataset/ci_videos"
99
print("[CI MODE] Only running on CI test videos...")
1010
else:
11-
videos_path = "fall_dataset/videos"
11+
videos_path = "fall_dataset/test_videos"
1212

1313
output_dir = "output_videos"
1414
os.makedirs(output_dir, exist_ok=True)

0 commit comments

Comments
 (0)