-
Notifications
You must be signed in to change notification settings - Fork 26
/
rtmo_demo.py
50 lines (36 loc) · 1.17 KB
/
rtmo_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 Body, draw_skeleton
# import numpy as np
device = 'cpu'
backend = 'onnxruntime' # opencv, onnxruntime, openvino
cap = cv2.VideoCapture(0)
openpose_skeleton = False # True for openpose-style, False for mmpose-style
body = Body(
pose='rtmo',
to_openpose=openpose_skeleton,
mode='balanced', # 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(frame)
det_time = time.time() - s
print('det: ', det_time)
img_show = frame.copy()
# if you want to use black background instead of original image,
# img_show = np.zeros(img_show.shape, dtype=np.uint8)
img_show = draw_skeleton(img_show,
keypoints,
scores,
openpose_skeleton=openpose_skeleton,
kpt_thr=0.3,
line_width=2)
img_show = cv2.resize(img_show, (960, 640))
cv2.imshow('img', img_show)
cv2.waitKey(10)