from mpipe import mpipe
import time
import pickle
import cv2
# import mediapipe as mp
# mp_drawing = mp.solutions.drawing_utils
# mp_drawing_styles = mp.solutions.drawing_styles
# mp_pose = mp.solutions.pose
with open('frames.dat', 'rb') as f:
imgs = pickle.load(f)
time1 = time.perf_counter()
mp = mpipe()
mp.detect(imgs[0])
# with mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5, model_complexity=1) as pose:
# imgs[0].flags.writeable = False
# results = pose.process(imgs[0])
time2 = time.perf_counter()
for img in imgs:
imrgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# imrgb = img.copy()
# imrgb.flags.writeable = False
# results = pose.process(imrgb)
# imrgb.flags.writeable = True
# if results.pose_landmarks:
# mp_drawing.draw_landmarks(
# imrgb,
# results.pose_landmarks,
# mp_pose.POSE_CONNECTIONS,
# landmark_drawing_spec=mp_drawing_styles.get_default_pose_landmarks_style())
mp.detect(imrgb)
time3 = time.perf_counter()
print("instance time: %.3fms" % ((time2-time1) * 1000))
print("process time: %.3fms/300 %.3fms/1" % (((time3-time2) * 1000), ((time3-time2) * 1000 / 300)))