Complete the code to import the MediaPipe Hands solution.
import mediapipe as mp mp_hands = mp.solutions.[1]
The MediaPipe Hands solution is accessed via mp.solutions.hands. This module provides hand landmark detection.
Complete the code to initialize the Hands model with static image mode enabled.
with mp_hands.Hands(static_image_mode=[1], max_num_hands=2) as hands:
Setting static_image_mode=True tells the model to treat input as static images, which is important for processing single images instead of video streams.
Fix the error in accessing the hand landmarks from the results object.
if results.[1]: for hand_landmarks in results.multi_hand_landmarks: print(hand_landmarks)
The detected hand landmarks are stored in results.multi_hand_landmarks. This attribute contains a list of landmarks for each detected hand.
Fill both blanks to draw hand landmarks on the image using MediaPipe drawing utilities.
mp_drawing.[1](image, hand_landmarks, mp_hands.[2])
The function draw_landmarks is used to draw landmarks on images. The connections for hands are accessed via mp_hands.HAND_CONNECTIONS.
Fill all three blanks to create a dictionary of landmark coordinates normalized to image size.
landmark_dict = [1]: {'x': [2].x * image_width, 'y': [2].y * image_height} for [1], [2] in [3](hand_landmarks.landmark)
This dictionary comprehension uses enumerate to get the index idx and landmark i. The index is used as the key, and the landmark coordinates are scaled by image width and height.