Search code examples
pythonmediapipepose

Access specific Pose Landmarker Task API on Python


I can't access to a specific landmarks with the new API using "vision.PoseLandmarker"

I used to use

import cv2
import mediapipe as mp

mp_pose = mp.solutions.pose

mp_drawing = mp.solutions.drawing_utils
cap = cv2.VideoCapture("video.mp4")

with mp_pose.Pose(
    static_image_mode = False) as pose:

if results.pose_landmarks is not None:
                
                x1 = int(results.pose_landmarks.landmark[16].x * width)
                y1 = int(results.pose_landmarks.landmark[16].y * height)

I tried use the official guide:

https://github.com/googlesamples/mediapipe/blob/main/examples/pose_landmarker/python/%5BMediaPipe_Python_Tasks%5D_Pose_Landmarker.ipynb

but it was impossible


Solution

  • The method to get a specific landmark with the new API is:

    x1 = int(results.pose_landmarks[0][mp_pose.PoseLandmark.NOSE].x * width)

    enter image description here