mediapipeface-landmark

Is the python face landmarks api available with mediapipe==0.9.1?


I'm trying to follow the example code for obtaining face landmarks with mediapipe. Unfortunately, vision.FaceLandmarkerOptions doesn't seem to exist.

After doing a little research, I believe the problem is that I'm running MacOS 10.15.7, which means that the highest supported revision of mediapipe I can install is 0.9.1. Unfortunately Apple no longer supports my machine, so I can't upgrade my OS.

Does my installed version of mediapipe simply not support face landmarks, or has the api merely changed and it's moved elsewhere, say, under solutions?

Any help would be appreciated,

-Scott


Solution

  • I have used mediapipe==0.9.1 and did face landmarks detection.

    import mediapipe as mp 
    
    face_mesh = mp.solutions.face_mesh.FaceMesh(
        max_num_faces=1,
        refine_landmarks=True,
        min_detection_confidence=0.5,
        static_image_mode=True,
        min_tracking_confidence=0.5
    )
    
    image = cv2.imread("image.png")
    result = face_mesh.process(image[:, :, ::-1])
    mp_drawing = mp.solutions.drawing_utils
    for face_landmarks in result.multi_face_landmarks:
                mp_drawing.draw_landmarks(
                    image=image,
                    landmark_list=face_landmarks,
    #                 connections=mp.solutions.face_mesh.FACE_CONNECTIONS,
                    landmark_drawing_spec=mp_drawing.DrawingSpec(color=(0, 255, 0), thickness=10, circle_radius=1),
                    connection_drawing_spec=mp_drawing.DrawingSpec(color=(0, 255, 255), thickness=1))
    
    

    image

    Notebook code is here: https://www.kaggle.com/code/sardorabdirayimov/mediapipe-v0-9-1

    Sincerely,