-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadLiveVideo
More file actions
49 lines (40 loc) · 2.32 KB
/
Copy pathReadLiveVideo
File metadata and controls
49 lines (40 loc) · 2.32 KB
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
%pip install mediapipe opencv-python
import mediapipe as mp
import cv2
mp_drawing = mp.solutions.drawing_utils
mp_holistic = mp.solutions.holistic
mp_drawing.DrawingSpec(color=(0,0,255), thickness=2, circle_radius=2)
mp_drawing.draw_landmarks
cap = cv2.VideoCapture(0)
with mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5) as holistic:
while cap.isOpened():
ret, frame = cap.read()
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
results = holistic.process(image)
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
# 1. Draw face landmarks
## (Decker) Face Landmark is not currently behaving itself. I'm going to comment it out for now.
#mp_drawing.draw_landmarks(image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS,
# mp_drawing.DrawingSpec(color=(80,110,10), thickness=1, circle_radius=1),
# mp_drawing.DrawingSpec(color=(80,256,121), thickness=1, circle_radius=1)
# )
# 2. Right hand
mp_drawing.draw_landmarks(image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS,
mp_drawing.DrawingSpec(color=(50,50,210), thickness=2, circle_radius=1),
mp_drawing.DrawingSpec(color=(0,0,221), thickness=2, circle_radius=1)
)
# 3. Left Hand
mp_drawing.draw_landmarks(image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS,
mp_drawing.DrawingSpec(color=(250,50,50), thickness=2, circle_radius=1),
mp_drawing.DrawingSpec(color=(200,0,0), thickness=2, circle_radius=1)
)
# 4. Pose Detections
mp_drawing.draw_landmarks(image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS,
mp_drawing.DrawingSpec(color=(245,117,66), thickness=2, circle_radius=1),
mp_drawing.DrawingSpec(color=(245,66,230), thickness=2, circle_radius=1)
)
cv2.imshow('Raw Webcam Feed', image)
if cv2.waitKey(10) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()