![]() |
VOOZH | about |
In this article, we will use mediapipe python library to detect face and hand landmarks. We will be using a Holistic model from mediapipe solutions to detect all the face and hand landmarks. We will be also seeing how we can access different landmarks of the face and hands which can be used for different computer vision applications such as sign language detection, drowsiness detection, etc.
Installing required libraries
pip install opencv-python mediapipe msvc-runtime
Below is the step-wise approach for Face and Hand landmarks detection
STEP-1: Import all the necessary libraries, In our case only two libraries are required.
STEP-2: Initializing Holistic model and Drawing utils for detecting and drawing landmarks on the image.
Let us look into the parameters for the Holistic Model:
Holistic( static_image_mode=False, model_complexity=1, smooth_landmarks=True, min_detection_confidence=0.5, min_tracking_confidence=0.5 )
STEP-3: Detecting Face and Hand landmarks from the image. Holistic model processes the image and produces landmarks for Face, Left Hand, Right Hand and also detects the Pose of the
The holistic model produces 468 Face landmarks, 21 Left-Hand landmarks, and 21 Right-Hand landmarks. The individual landmarks can be accessed by specifying the index of the required landmark. Example: results.left_hand_landmarks.landmark[0]. You can get the index of all the individual landmarks using the below code:
HandLandmark.WRIST 0 HandLandmark.THUMB_CMC 1 HandLandmark.THUMB_MCP 2 HandLandmark.THUMB_IP 3 HandLandmark.THUMB_TIP 4 HandLandmark.INDEX_FINGER_MCP 5 HandLandmark.INDEX_FINGER_PIP 6 HandLandmark.INDEX_FINGER_DIP 7 HandLandmark.INDEX_FINGER_TIP 8 HandLandmark.MIDDLE_FINGER_MCP 9 HandLandmark.MIDDLE_FINGER_PIP 10 HandLandmark.MIDDLE_FINGER_DIP 11 HandLandmark.MIDDLE_FINGER_TIP 12 HandLandmark.RING_FINGER_MCP 13 HandLandmark.RING_FINGER_PIP 14 HandLandmark.RING_FINGER_DIP 15 HandLandmark.RING_FINGER_TIP 16 HandLandmark.PINKY_MCP 17 HandLandmark.PINKY_PIP 18 HandLandmark.PINKY_DIP 19 HandLandmark.PINKY_TIP 20 0
OUTPUT: