From a4bdfc2062e84df6ce83965f6358a1b726c563ca Mon Sep 17 00:00:00 2001 From: LinasKo Date: Tue, 11 Jun 2024 13:51:23 +0300 Subject: [PATCH] minor tidy-up for mediapipe --- supervision/keypoint/core.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/supervision/keypoint/core.py b/supervision/keypoint/core.py index ac889bc5..374bb2a1 100644 --- a/supervision/keypoint/core.py +++ b/supervision/keypoint/core.py @@ -216,11 +216,12 @@ class KeyPoints: image = cv2.imread() image_height, image_width, _ = image.shape - mp_image = mp.Image( + mediapipe_image = mp.Image( image_format=mp.ImageFormat.SRGB, data=cv2.cvtColor(image, cv2.COLOR_BGR2RGB), ) + # Download model task from: https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker/index#models options = mp.tasks.vision.PoseLandmarkerOptions( base_options=mp.tasks.BaseOptions( model_asset_path="pose_landmarker_heavy.task" @@ -231,27 +232,10 @@ class KeyPoints: PoseLandmarker = mp.tasks.vision.PoseLandmarker with PoseLandmarker.create_from_options(options) as landmarker: - pose_landmarker_result = landmarker.detect(mp_image) + pose_landmarker_result = landmarker.detect(mediapipe_image) keypoints = sv.KeyPoints.from_mediapipe( - pose_landmarker_result, [image_width, image_height] - ) - ``` - - ```python - import cv2 - import mediapipe as mp - import supervision as sv - - image = cv2.imread() - image_height, image_width, _ = image.shape - pose = mp.solutions.pose.Pose( - static_image_mode=True, - min_detection_confidence=0.5, - ) - results = pose.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) - keypoints = sv.KeyPoints.from_mediapipe( - pose_landmarker_result, [image_width, image_height] + pose_landmarker_result, (image_width, image_height) ) ``` """