-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblazepose test.py
54 lines (43 loc) · 1.41 KB
/
blazepose test.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
51
52
53
54
import cv2
import time
import mediapipe as mp
from constants import VIDEO_FILE, VIDEO_FILE_PATH
mp_drawing = mp.solutions.drawing_utils
mp_drawing_styles = mp.solutions.drawing_styles
mp_pose = mp.solutions.pose
avg = 0
count = 1
file = VIDEO_FILE_PATH + VIDEO_FILE
#cap = cv2.VideoCapture(file)
cap = cv2.VideoCapture('Dataset/Yoga/Tester/82.mp4')
with mp_pose.Pose(
model_complexity=0,
min_detection_confidence=0.5,
min_tracking_confidence=0.5) as pose:
while cap.isOpened():
success, image = cap.read()
if not success:
print("no video in frame")
continue
start_time = time.time()
image.flags.writeable = False
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = cv2.resize(image, (500, 700))
result = pose.process(image)
image.flags.writeable = True
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
mp_drawing.draw_landmarks(
image,
result.pose_landmarks,
mp_pose.POSE_CONNECTIONS,
landmark_drawing_spec=mp_drawing_styles.get_default_pose_landmarks_style()
)
cv2.imshow('media pipe pose', cv2.flip(image, 1))
end_time = time.time()
fps = 1 / (end_time - start_time)
avg += fps
count += 1
if cv2.waitKey(5) & 0xFF == 27:
break
print("average fps is ", avg / count)
cap.release()