import mediapipe as mp | |
import cv2 | |
import numpy as np | |
class PoseDetector: | |
def __init__(self): | |
self.mp_pose = mp.solutions.pose | |
self.pose = self.mp_pose.Pose( | |
min_detection_confidence=0.5, | |
min_tracking_confidence=0.5 | |
) | |
def detect_pose(self, frame): | |
# Convert BGR to RGB | |
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) | |
# Process the frame and detect poses | |
results = self.pose.process(rgb_frame) | |
if results.pose_landmarks: | |
return results.pose_landmarks | |
return None |