import mediapipe as mp from utils import read_n_resize def mp_pose_estimation_fn(image): mp_drawing = mp.solutions.drawing_utils mp_drawing_styles = mp.solutions.drawing_styles mp_pose = mp.solutions.pose with mp_pose.Pose( static_image_mode=True, model_complexity=2, enable_segmentation=True, min_detection_confidence=0.5 ) as pose: image = read_n_resize(image, read=False) results = pose.process(image) annotated_image = image.copy() # Draw pose landmarks on the image. mp_drawing.draw_landmarks( annotated_image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS, landmark_drawing_spec=mp_drawing_styles.get_default_pose_landmarks_style() ) return annotated_image