-
Notifications
You must be signed in to change notification settings - Fork 38
/
holistic.py
55 lines (44 loc) · 1.68 KB
/
holistic.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 as mp
from videosource import WebcamSource
mp_drawing = mp.solutions.drawing_utils
mp_holistic = mp.solutions.holistic
mp_face_mesh_connections = mp.solutions.face_mesh_connections
drawing_spec = mp_drawing.DrawingSpec(thickness=1, circle_radius=3)
def main():
source = WebcamSource()
with mp_holistic.Holistic(
min_detection_confidence=0.5, min_tracking_confidence=0.5
) as holistic:
for idx, (frame, frame_rgb) in enumerate(source):
results = holistic.process(frame_rgb)
mp_drawing.draw_landmarks(
frame,
results.face_landmarks,
connections=mp_face_mesh_connections.FACEMESH_TESSELATION,
landmark_drawing_spec=drawing_spec,
connection_drawing_spec=drawing_spec,
)
mp_drawing.draw_landmarks(
frame,
results.left_hand_landmarks,
mp_holistic.HAND_CONNECTIONS,
landmark_drawing_spec=drawing_spec,
connection_drawing_spec=drawing_spec,
)
mp_drawing.draw_landmarks(
frame,
results.right_hand_landmarks,
mp_holistic.HAND_CONNECTIONS,
landmark_drawing_spec=drawing_spec,
connection_drawing_spec=drawing_spec,
)
mp_drawing.draw_landmarks(
frame,
results.pose_landmarks,
mp_holistic.POSE_CONNECTIONS,
landmark_drawing_spec=drawing_spec,
connection_drawing_spec=drawing_spec,
)
source.show(frame)
if __name__ == "__main__":
main()