Skip to content

Instantly share code, notes, and snippets.

@J22Melody
Last active July 24, 2023 12:09
Show Gist options
  • Save J22Melody/72b85a2e01918e47479faec0d257774c to your computer and use it in GitHub Desktop.
Save J22Melody/72b85a2e01918e47479faec0d257774c to your computer and use it in GitHub Desktop.
Operate Mediapipe Holistic poses
def restore_dimensions(pose: Pose, weight: float, height: float) -> Pose:
import numpy as np
pose.body.data = pose.body.data * np.array([width, height, 1.0])
return pose
def reduce_holistic(pose: Pose) -> Pose:
import mediapipe as mp
points_set = set([p for p_tup in list(mp.solutions.holistic.FACEMESH_CONTOURS) for p in p_tup])
face_contours = [str(p) for p in sorted(points_set)]
components = [c.name for c in pose.header.components]
return pose.get_components(components, {"FACE_LANDMARKS": face_contours})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment