Hook
More breakout videos from this creator.
Computer Vision pt 1: Hand Tracking using existing libraries. What can we do with these tools? And how do they work? I’ll start a series building on top of this so we can build some pretty cool stuff! #computervision #ml #programming #coding This is how you can code a script that does hand tracking using Python in real time. We'll only need two libraries: OpenCV to capture your frames and Mediapipe that already comes with a hand tracking model. So you pretty much won't have to train anything. We can start in a new directory and install the required packages. So we're going to create a main.py file. Here we're going to import OpenCV and Mediapipe. We'll initialize the camera. Now we'll create the Mediapipe Hands object. And I'm putting it in a with statement so that when we're done, we can clean up all the resources. Inside this statement, index 0 means it'll grab the first available on camera. Here we start the Hands object. As hands. Frame capture loop: while cam.isOpened(): success, frame = cam.read() if not success: print("Empty frame.") continue # Converting color format: frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) results = hands.process(frame_rgb) # If hands landmarks in results.multi_hand_landmarks: for hand_landmarks in results.multi_hand_landmarks: mp_drawing.draw_landmarks( image=frame, landmark_list=hand_landmarks, connections=mp_hands.HAND_CONNECTIONS, landmark_drawing_spec=mp_drawing_styles.get_default_hand_landmarks_style(), connection_drawing_spec=mp_drawing_styles.get_default_hand_connections_style()) # Display window and flip frame: cv2.imshow("Hand tracking", cv2.flip(frame, 1)) # Exit using the Q key: if cv2.waitKey(1) & 0xFF == ord("q"): break cam.release() cv2.destroyAllWindows() if __name__ == "__main__": run_hand_tracking_on_webcam This is what it looks like when we are running it. And in the next video, we can add more features and interactions to this script.