This project demonstrates how to control the mouse cursor using finger movements tracked by a webcam. The project uses Python and OpenCV to process real-time video, detect hand gestures, and move the cursor accordingly. The goal is to create a simple, efficient, and intuitive virtual mouse system
-
Python 3.x
-
OpenCV (cv2)
-
MediaPipe (mediapipe)
-
PyAutoGUI (pyautogui)
pip install opencv-python mediapipe pyautogui
- Hand Detection: The project uses MediaPipe to identify the user's hand in real-time video. It locates key landmarks on the hand (such as finger tips and knuckles).
- Finger Tracking: The landmarks of the index and middle fingers are used to track the movement of the fingers and translate that into mouse movements. The distance between fingers can also be used to simulate mouse clicks.
- Mouse Control: Using the pyautogui library, finger movements are translated into actions on the screen. The index finger controls the cursor's position, and gestures involving the thumb and other fingers trigger click or scroll actions.
- Index Finger Movement: Controls the movement of the cursor.
- Pinch Gesture: Thumb and index finger together simulate a left-click.
- Three Finger Gesture: Move three fingers together to scroll the window up or down.
- Index and Middle Finger Gesture: Hold both fingers up to simulate right-click
Here’s a simple demo of how the project works:
- Lighting Conditions: The accuracy of hand detection may vary depending on the lighting conditions.
- Webcam Resolution: Using a low-quality webcam can reduce detection accuracy and response time.
- CPU Usage: Real-time video processing can be resource-intensive; using a more powerful computer may improve performance.
- Improved gesture recognition for additional control features.
- Enhanced stability and reduced latency for smoother control.
- Integration with additional gesture-based libraries for more functionalities.