import mediapipe as mp import cv2 import numpy as np mp_holistic = mp.solutions.holistic def extract_keypoints_from_frame(frame): with mp_holistic.Holistic(static_image_mode=True) as holistic: results = holistic.process(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) if results.pose_landmarks and results.left_hand_landmarks and results.right_hand_landmarks: pose = np.array([[p.x, p.y, p.z] for p in results.pose_landmarks.landmark]) left = np.array([[p.x, p.y, p.z] for p in results.left_hand_landmarks.landmark]) right = np.array([[p.x, p.y, p.z] for p in results.right_hand_landmarks.landmark]) return np.concatenate([pose, left, right], axis=0).flatten() return np.random.random(33*3 + 21*3*2) # fallback