-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathbody_with_feet_demo.py
50 lines (39 loc) · 1.28 KB
/
body_with_feet_demo.py
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
44
45
46
47
48
49
50
import time
import cv2
from rtmlib import BodyWithFeet, PoseTracker, draw_skeleton
device = 'cpu'
backend = 'onnxruntime' # opencv, onnxruntime, openvino
cap = cv2.VideoCapture(0) # Video file path
openpose_skeleton = False # True for openpose-style, False for mmpose-style
body_feet_tracker = PoseTracker(
BodyWithFeet,
det_frequency=7,
to_openpose=openpose_skeleton,
mode='performance', # balanced, performance, lightweight
backend=backend,
device=device)
frame_idx = 0
while cap.isOpened():
success, frame = cap.read()
frame_idx += 1
if not success:
break
s = time.time()
keypoints, scores = body_feet_tracker(frame)
det_time = time.time() - s
print('det: ', det_time)
img_show = frame.copy()
img_show = draw_skeleton(img_show,
keypoints,
scores,
openpose_skeleton=openpose_skeleton,
kpt_thr=0.3,
line_width=3)
img_show = cv2.resize(img_show, (960, 640))
while True:
cv2.imshow('Body and Feet Pose Estimation', img_show)
key = cv2.waitKey(1) & 0xFF
if key == ord('q'): # Press 'q' to exit
break
cap.release()
cv2.destroyAllWindows()