forked from interfacew/GestureMate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.py
55 lines (51 loc) · 2.33 KB
/
Utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import mediapipe.python.solutions as sol
def drawLandmarks(image, results):
# Draw face connections
sol.drawing_utils.draw_landmarks(image, results.face_landmarks, sol.holistic.FACEMESH_TESSELATION,
landmark_drawing_spec=None, connection_drawing_spec=sol.drawing_styles.get_default_face_mesh_tesselation_style())
sol.drawing_utils.draw_landmarks(image, results.face_landmarks, sol.holistic.FACEMESH_CONTOURS,
landmark_drawing_spec=None, connection_drawing_spec=sol.drawing_styles.get_default_face_mesh_contours_style())
# Draw pose connections
sol.drawing_utils.draw_landmarks(
image, results.pose_landmarks, sol.holistic.POSE_CONNECTIONS, sol.drawing_styles.get_default_pose_landmarks_style())
# Draw left hand connections
sol.drawing_utils.draw_landmarks(image, results.left_hand_landmarks, sol.holistic.HAND_CONNECTIONS,
sol.drawing_styles.get_default_hand_landmarks_style(), sol.drawing_styles.get_default_hand_connections_style())
# Draw right hand connections
sol.drawing_utils.draw_landmarks(image, results.right_hand_landmarks, sol.holistic.HAND_CONNECTIONS,
sol.drawing_styles.get_default_hand_landmarks_style(), sol.drawing_styles.get_default_hand_connections_style())
def extractLandmarks(x):
res = {}
if not x.pose_landmarks is None:
a = x.pose_landmarks.landmark
b = []
for i in range(len(a)):
b.append([a[i].x, a[i].y, a[i].z])
res['body'] = b
else:
res['body'] = None
if not x.left_hand_landmarks is None:
a = x.left_hand_landmarks.landmark
b = []
for i in range(len(a)):
b.append([a[i].x, a[i].y, a[i].z])
res['rightHand'] = b
else:
res['rightHand'] = None
if not x.right_hand_landmarks is None:
a = x.right_hand_landmarks.landmark
b = []
for i in range(len(a)):
b.append([a[i].x, a[i].y, a[i].z])
res['leftHand'] = b
else:
res['leftHand'] = None
if not x.face_landmarks is None:
a = x.face_landmarks.landmark
b = []
for i in range(len(a)):
b.append([a[i].x, a[i].y, a[i].z])
res['face'] = b
else:
res['face'] = None
return res