-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.py
36 lines (27 loc) · 975 Bytes
/
main.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
import cv2
from lkcomputervision import MediaPipeHandler
# Initialize the MediaPipeHandler
mp = MediaPipeHandler()
# Capture video from the webcam (you can also specify a video file path)
cap = cv2.VideoCapture(0) # 0 represents the default webcam
while True:
# Read a frame from the video capture
ret, frame = cap.read()
if not ret:
break
# Process the frame to track hands
#result = mp.trackHands(frame)
#result = mp.detectFace(frame)
#result = mp.detectPose(frame)
result = mp.faceMesh(frame)
# Retrieve the frame with hand landmarks drawn on it
frame_with_landmarks = result["frame"]
print(result["landmarks"])
# Display the frame with landmarks
cv2.imshow("Hand Tracking", frame_with_landmarks)
# Exit the loop when the user presses the 'q' key
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the video capture and close the OpenCV windows
cap.release()
cv2.destroyAllWindows()