| import cv2 |
| import mediapipe as mp |
|
|
| |
| mphands = mp.solutions.hands |
| mpdrawing = mp.solutions.drawing_utils |
|
|
| |
| vids =[ |
| '/home/stevend/Documents/Notebooks/Dia1/videos/mano1.mp4', |
| '/home/stevend/Documents/Notebooks/Dia1/videos/mano2.mp4', |
| '/home/stevend/Documents/Notebooks/Dia1/videos/mano3.mp4', |
| '/home/stevend/Documents/Notebooks/Dia1/videos/mano4.mp4', |
| '/home/stevend/Documents/Notebooks/Dia1/videos/mano5.mp4', |
| '/home/stevend/Documents/Notebooks/Dia1/videos/parkinzon.mp4', |
| '/home/stevend/Documents/Notebooks/Dia1/videos/dedo_gatillo.mp4' |
| ] |
| vidpath = vids[6] |
|
|
| |
| vidcap = cv2.VideoCapture(vidpath) |
|
|
| |
| winwidth = 350 |
| winheight = 600 |
|
|
| |
| with mphands.Hands(min_detection_confidence=0.5, min_tracking_confidence=0.5) as hands: |
| while vidcap.isOpened(): |
| ret, frame = vidcap.read() |
| if not ret: |
| break |
|
|
| |
| rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) |
|
|
| |
| processFrames = hands.process(rgb_frame) |
|
|
| |
| if processFrames.multi_hand_landmarks: |
| for lm in processFrames.multi_hand_landmarks: |
| mpdrawing.draw_landmarks(frame, lm, mphands.HAND_CONNECTIONS) |
|
|
| |
| resized_frame = cv2.resize(frame, (winwidth, winheight)) |
|
|
| |
| cv2.imshow('Hand Tracking', resized_frame) |
|
|
| |
| if cv2.waitKey(1) & 0xFF == ord('q'): |
| break |
|
|
| |
| vidcap.release() |
| cv2.destroyAllWindows() |