Skip to content

Commit

Permalink
add demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tau-J committed Sep 30, 2023
1 parent 3677a37 commit 14d6453
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
42 changes: 42 additions & 0 deletions rtmlib/tools/solution/body.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
'''
Example:
import cv2
from rtmlib import Body, draw_skeleton
device = 'cuda'
backend = 'onnxruntime' # opencv, onnxruntime
cap = cv2.VideoCapture('./demo.mp4')
openpose_skeleton = True # True for openpose-style, False for mmpose-style
body = Body(to_openpose=openpose_skeleton,
backend=backend,
device=device)
frame_idx = 0
while cap.isOpened():
success, frame = cap.read()
frame_idx += 1
if not success:
break
keypoints, scores = body(frame)
img_show = frame.copy()
img_show = draw_skeleton(img_show,
keypoints,
scores,
openpose_skeleton=openpose_skeleton,
kpt_thr=0.43)
img_show = cv2.resize(img_show, (960, 540))
cv2.imshow('img', img_show)
cv2.waitKey(10)
'''
import numpy as np

from .. import YOLOX, RTMPose
Expand Down
42 changes: 42 additions & 0 deletions rtmlib/tools/solution/wholebody.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
'''
Example:
import cv2
from rtmlib import Wholebody, draw_skeleton
device = 'cuda'
backend = 'onnxruntime' # opencv, onnxruntime
cap = cv2.VideoCapture('./demo.mp4')
openpose_skeleton = True # True for openpose-style, False for mmpose-style
wholebody = Wholebody(to_openpose=openpose_skeleton,
backend=backend,
device=device)
frame_idx = 0
while cap.isOpened():
success, frame = cap.read()
frame_idx += 1
if not success:
break
keypoints, scores = wholebody(frame)
img_show = frame.copy()
img_show = draw_skeleton(img_show,
keypoints,
scores,
openpose_skeleton=openpose_skeleton,
kpt_thr=0.43)
img_show = cv2.resize(img_show, (960, 540))
cv2.imshow('img', img_show)
cv2.waitKey(10)
'''
from typing import List, Optional

import numpy as np
Expand Down

0 comments on commit 14d6453

Please sign in to comment.