Reputation: 11
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:
but it was impossible
Upvotes: 0
Views: 293
Reputation: 11
The method to get a specific landmark with the new API is:
x1 = int(results.pose_landmarks[0][mp_pose.PoseLandmark.NOSE].x * width)
Upvotes: 0
Reputation: 7566
According to the API reference, the detect
method returns a PoseLandmarkerResult
object with three properties: pose_landmarks
, pose_world_landmarks
, and the optional segmentation_masks
:
mp.tasks.vision.PoseLandmarkerResult(
pose_landmarks: List[List[landmark_module.NormalizedLandmark]],
pose_world_landmarks: List[List[landmark_module.Landmark]],
segmentation_masks: Optional[List[image_module.Image]] = None
)
So to get the x coordinate of a specific landmark, for example, you can do the following:
detection_result.pose_landmarks[0][0].x
Upvotes: 0