A real-time hand gesture recognition application that allows you to control your computer (scrolling and media playback [TODO]) using simple hand movements captured by your webcam.
Built with MediaPipe for hand detection and OpenCV for camera handling.
- Scroll Up and Scroll Down using index and middle finger gestures
- Play / Pause media with pinky finger gesture
- Global hotkey to start/stop gesture control
- Real-time hand landmark visualization with circles and lines
- Audio feedback with beeps
- Simple gesture-based control
- MediaPipe – Hand landmark detection
- OpenCV – Webcam access and image display
- pynput – Global hotkey support
- keyboard – Keyboard input simulation
- NumPy – Distance calculations
- Pycaw – System volume control (currently commented)
Python 3.9 - 3.11 (64-bit) recommended
Install all dependencies with this single command:
pip install mediapipe opencv-python pycaw comtypes keyboard pynput numpy- Clone or download this repository
- Open Command Prompt or Terminal as Administrator
- Install the required libraries using the command above
- Save the main code as
gesture_control.pyin the project folder - Run the application:
python contro2l.pyAfter running the script, the program starts in waiting mode and prints "waiting..".
- Press the hotkey Ctrl + Alt + Cmd (Ctrl + Alt + Windows key) to activate gesture control
- The camera window titled "Image" will open
- Show your right or left hand clearly to the webcam
- Scroll Down: Move index finger down while thumb is close to index finger
- Scroll Up: Move middle finger up while thumb is close to index finger
- Play / Pause: Spread pinky finger far from thumb (triggers toggle with beep sound)
- Press Ctrl + Alt + Cmd again to stop gesture mode (cmd is the win button in windows)
- Press Spacebar in the camera window to completely exit
- Ensure good lighting on your hand
- Keep your hand 30–60 cm away from the webcam
- Avoid very fast movements for more accurate detection
- If the hotkey doesn't work, try changing it in the code to
<ctrl>+<alt>+h
- Hotkey using
<cmd>(Windows key) can sometimes be unstable with pynput. Use<ctrl>+<alt>+has backup if needed. - Pinky detection uses landmark 18 (not the tip). This may be improved later.
- Volume control code is commented out and can be enabled easily.
- Zoom gestures are detected but not implemented yet.
- Enable volume control using thumb-index distance
- Add actual zoom functionality
- Implement mouse cursor control
- Improve gesture smoothness and add filtering