-1

AttributeError: module 'mediapipe.python.solutions.holistic' has no attribute 'LEFT_HAND_LANDMARKS' I am trying to use left hand landmarks in mediapipe holistic model but it gives error that it has no attribute of LEFT_HAND_LANDMARKS

I were expecting to get 21 landmarks of hand defined in mediapipe solution.

1 Answers1

0

The landmarks are found in holistic.process() after you've passed in your frame or image.

results = holistic.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))

Here, I am converting my BGR image to RGB using opencv and passing it into the holistic.processs() function. After which you can access each landmark from the results variable.

Access the hand landmarks with results.left_hand_landmarks or results.right_hand_landmarks

with  mp_holistic.Holistic(static_image_mode=True) as holistic:
        results = holistic.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
        
        pose = np.array([[res.x, res.y, res.z, res.visibility] for res in results.pose_landmarks.landmark]).flatten() if results.pose_landmarks else np.zeros(33*4)
        face = np.array([[res.x, res.y, res.z] for res in results.face_landmarks.landmark]).flatten() if results.face_landmarks else np.zeros(468*3)
        lh = np.array([[res.x, res.y, res.z] for res in results.left_hand_landmarks.landmark]).flatten() if results.left_hand_landmarks else np.zeros(21*3)
        rh = np.array([[res.x, res.y, res.z] for res in results.right_hand_landmarks.landmark]).flatten() if results.right_hand_landmarks else np.zeros(21*3)

Hope this helps. :)

Samdon
  • 1
  • 1