Exemple #1
0
def get_default_face_mesh_iris_connections_style(
) -> Mapping[Tuple[int, int], DrawingSpec]:
  """Returns the default face mesh iris connections drawing style.

  Returns:
       A mapping from each iris connection to its default drawing spec.
  """
  face_mesh_iris_connections_style = {}
  left_spec = DrawingSpec(color=_GREEN, thickness=_THICKNESS_CONTOURS)
  for connection in face_mesh_connections.FACEMESH_LEFT_IRIS:
    face_mesh_iris_connections_style[connection] = left_spec
  right_spec = DrawingSpec(color=_RED, thickness=_THICKNESS_CONTOURS)
  for connection in face_mesh_connections.FACEMESH_RIGHT_IRIS:
    face_mesh_iris_connections_style[connection] = right_spec
  return face_mesh_iris_connections_style
Exemple #2
0
def get_default_face_mesh_tesselation_style() -> DrawingSpec:
    """Returns the default face mesh tesselation drawing style.

  Returns:
      A DrawingSpec.
  """
    return DrawingSpec(color=_GRAY, thickness=_THICKNESS_TESSELATION)
Exemple #3
0
def get_default_pose_landmarks_style() -> Mapping[int, DrawingSpec]:
    """Returns the default pose landmarks drawing style.

  Returns:
      A mapping from each pose landmark to its default drawing spec.
  """
    pose_landmark_style = {}
    left_spec = DrawingSpec(color=(0, 138, 255),
                            thickness=_THICKNESS_POSE_LANDMARKS)
    right_spec = DrawingSpec(color=(231, 217, 0),
                             thickness=_THICKNESS_POSE_LANDMARKS)
    for landmark in _POSE_LANDMARKS_LEFT:
        pose_landmark_style[landmark] = left_spec
    for landmark in _POSE_LANDMARKS_RIGHT:
        pose_landmark_style[landmark] = right_spec
    pose_landmark_style[PoseLandmark.NOSE] = DrawingSpec(
        color=_WHITE, thickness=_THICKNESS_POSE_LANDMARKS)
    return pose_landmark_style
Exemple #4
0
_THUMP_LANDMARKS = (HandLandmark.THUMB_MCP, HandLandmark.THUMB_IP,
                    HandLandmark.THUMB_TIP)
_INDEX_FINGER_LANDMARKS = (HandLandmark.INDEX_FINGER_PIP,
                           HandLandmark.INDEX_FINGER_DIP,
                           HandLandmark.INDEX_FINGER_TIP)
_MIDDLE_FINGER_LANDMARKS = (HandLandmark.MIDDLE_FINGER_PIP,
                            HandLandmark.MIDDLE_FINGER_DIP,
                            HandLandmark.MIDDLE_FINGER_TIP)
_RING_FINGER_LANDMARKS = (HandLandmark.RING_FINGER_PIP,
                          HandLandmark.RING_FINGER_DIP,
                          HandLandmark.RING_FINGER_TIP)
_PINKY_FINGER_LANDMARKS = (HandLandmark.PINKY_PIP, HandLandmark.PINKY_DIP,
                           HandLandmark.PINKY_TIP)
_HAND_LANDMARK_STYLE = {
    _PALM_LANMARKS:
    DrawingSpec(color=_RED, thickness=_THICKNESS_DOT, circle_radius=_RADIUS),
    _THUMP_LANDMARKS:
    DrawingSpec(color=_PEACH, thickness=_THICKNESS_DOT, circle_radius=_RADIUS),
    _INDEX_FINGER_LANDMARKS:
    DrawingSpec(color=_PURPLE, thickness=_THICKNESS_DOT,
                circle_radius=_RADIUS),
    _MIDDLE_FINGER_LANDMARKS:
    DrawingSpec(color=_YELLOW, thickness=_THICKNESS_DOT,
                circle_radius=_RADIUS),
    _RING_FINGER_LANDMARKS:
    DrawingSpec(color=_GREEN, thickness=_THICKNESS_DOT, circle_radius=_RADIUS),
    _PINKY_FINGER_LANDMARKS:
    DrawingSpec(color=_BLUE, thickness=_THICKNESS_DOT, circle_radius=_RADIUS),
}

# Hands connections
Exemple #5
0
import collections
from statistics import mean

import cv2
import numpy as np
from mediapipe.python.solutions.drawing_utils import DrawingSpec, RED_COLOR
from numpy.linalg import lstsq
from scipy import stats

landmark_drawing_spec: DrawingSpec = DrawingSpec(color=RED_COLOR)

deque_l = 5

x0_d = collections.deque(deque_l * [0.], deque_l)
y0_d = collections.deque(deque_l * [0.], deque_l)

x1_d = collections.deque(deque_l * [0.], deque_l)
y1_d = collections.deque(deque_l * [0.], deque_l)

z_val_f_d = collections.deque(deque_l * [0.], deque_l)
z_val_s_d = collections.deque(deque_l * [0.], deque_l)

m_xy_d = collections.deque(deque_l * [0.], deque_l)
c_xy_d = collections.deque(deque_l * [0.], deque_l)

x_d = collections.deque(deque_l * [0.], deque_l)
y_d = collections.deque(deque_l * [0.], deque_l)
z_d = collections.deque(deque_l * [0.], deque_l)


def read_depth_png(path):
def get_face_landmark_style():
    """Returns the default hand landmark drawing style.

    Returns:
        A mapping from each hand landmark to the default drawing spec.
    """
    key_flm_style = get_key_flm(is_all=True)
    style = {
        key_flm_style['lips']:
        DrawingSpec(color=RED_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS),
        key_flm_style['left_eye']:
        DrawingSpec(color=BLACK_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS + 1),
        key_flm_style['left_eyebrow']:
        DrawingSpec(color=BROWN_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS),
        key_flm_style['right_eye']:
        DrawingSpec(color=BLACK_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS + 1),
        key_flm_style['right_eyebrow']:
        DrawingSpec(color=BROWN_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS),
        key_flm_style['face_oval']:
        DrawingSpec(color=BLUE_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS),
        key_flm_style['jaw']:
        DrawingSpec(color=CYAN_COLOR,
                    thickness=_THICKNESS_DOT + 1,
                    circle_radius=_RADIUS + 1),
        key_flm_style['nose']:
        DrawingSpec(color=CORAL_COLOR,
                    thickness=_THICKNESS_DOT + 1,
                    circle_radius=_RADIUS + 1),
        key_flm_style['right_cheek']:
        DrawingSpec(color=RED_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS + 3),
        key_flm_style['left_check']:
        DrawingSpec(color=RED_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS + 3),
        key_flm_style['midway']:
        DrawingSpec(color=GRAY_COLOR,
                    thickness=_THICKNESS_DOT + 1,
                    circle_radius=_RADIUS + 1),
        key_flm_style['others']:
        DrawingSpec(color=GREEN_COLOR,
                    thickness=_THICKNESS_DOT,
                    circle_radius=_RADIUS),
    }

    face_landmark_style = {}
    for k, v in style.items():
        for landmark in k:
            face_landmark_style[landmark] = v
    return face_landmark_style