From a24d22253f89f62ee715e2ebae39e4812912ca17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20T=C5=82uchowski?= <134616904+SykkoAtHome@users.noreply.github.com> Date: Tue, 26 Aug 2025 12:07:41 +0200 Subject: [PATCH] fix: handle landmark lists --- core/face_detector.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/face_detector.py b/core/face_detector.py index c407bdb..bdbda27 100644 --- a/core/face_detector.py +++ b/core/face_detector.py @@ -95,8 +95,16 @@ class FaceDetector: # Get image dimensions for coordinate conversion image_height, image_width = image_np.shape[:2] - # Extract landmark coordinates - for idx, landmark in enumerate(face_landmarks.landmark): + # Extract landmark coordinates. MediaPipe may return a + # NormalizedLandmarkList object (with a `landmark` attribute) + # or simply a list of `Landmark` objects depending on the API + # (Solutions vs Tasks). The previous implementation assumed the + # former and failed with `'list' object has no attribute + # "landmark"' when using the Tasks API. To support both + # structures we access the iterable safely. + landmarks_iter = getattr(face_landmarks, 'landmark', face_landmarks) + + for idx, landmark in enumerate(landmarks_iter): # Convert normalized coordinates to pixel coordinates x = landmark.x * image_width y = landmark.y * image_height