-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (27 loc) · 1.03 KB
/
main.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
import cv2
import mediapipe as mp
import numpy as np
mp_pose = mp.solutions.pose
mp_draw = mp.solutions.drawing_utils
pose = mp_pose.Pose()
# cap = cv2.VideoCapture("vid.mp4")
cap = cv2.VideoCapture(0)
while True:
ret, img = cap.read()
img = cv2.resize(img, (600, 400))
results = pose.process(img)
mp_draw.draw_landmarks(img, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,
mp_draw.DrawingSpec((255, 0, 0), 2, 2),
mp_draw.DrawingSpec((255, 0, 255), 2, 2)
)
cv2.imshow("Pose Estimation", img)
h, w, c = img.shape
opImg = np.zeros([h, w, c])
opImg.fill(0)
mp_draw.draw_landmarks(opImg, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,
mp_draw.DrawingSpec((255, 0, 0), 2, 2),
mp_draw.DrawingSpec((255, 0, 255), 2, 2)
)
cv2.imshow("Extracted Pose", opImg)
print(results.pose_landmarks)
cv2.waitKey(1)