-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathpose_detect.py
More file actions
25 lines (19 loc) · 810 Bytes
/
pose_detect.py
File metadata and controls
25 lines (19 loc) · 810 Bytes
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
import cv2
import argparse
from openpose import Openpose, draw_person_pose
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Pose detector')
parser.add_argument('weights', help='weights file path')
parser.add_argument('--img', '-i', help='image file path')
parser.add_argument('--precise', '-p', action='store_true', help='do precise inference')
args = parser.parse_args()
# load model
openpose = Openpose(weights_file = args.weights, training = False)
# read image
img = cv2.imread(args.img)
# inference
poses, _ = openpose.detect(img, precise=args.precise)
# draw and save image
img = draw_person_pose(cv2.cvtColor(img, cv2.COLOR_BGR2RGB), poses)
print('Saving result into result.png...')
cv2.imwrite('result.png', img)