From ca031e1828a7766bde8844133988323b592e7225 Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Sun, 27 Apr 2025 12:56:45 +0200 Subject: [PATCH] Fix linting --- node-hub/dora-mediapipe/dora_mediapipe/main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/node-hub/dora-mediapipe/dora_mediapipe/main.py b/node-hub/dora-mediapipe/dora_mediapipe/main.py index 6a9ceedb..048e0b12 100644 --- a/node-hub/dora-mediapipe/dora_mediapipe/main.py +++ b/node-hub/dora-mediapipe/dora_mediapipe/main.py @@ -13,6 +13,7 @@ mp_draw = mp.solutions.drawing_utils def get_3d_coordinates(landmark, depth_frame, w, h, resolution, focal_length): + """Convert 2D landmark coordinates to 3D coordinates.""" cx, cy = int(landmark.x * w), int(landmark.y * h) if 0 < cx < w and 0 < cy < h: depth = depth_frame[cy, cx] / 1_000.0 @@ -27,7 +28,13 @@ def get_3d_coordinates(landmark, depth_frame, w, h, resolution, focal_length): return [0, 0, 0] -def get_image(event): +def get_image(event: dict) -> np.ndarray: + """Convert the image from the event to a numpy array. + + Args: + event (dict): The event containing the image data. + + """ storage = event["value"] metadata = event["metadata"] encoding = metadata["encoding"] @@ -116,7 +123,7 @@ def main(): print("No pose landmarks detected.") elif "depth" in event_id: metadata = event["metadata"] - encoding = metadata["encoding"] + _encoding = metadata["encoding"] width = metadata["width"] height = metadata["height"] focal_length = metadata["focal_length"]