Computer Vision Project to Control YouTube Using Hand Gestures
This guide will help you set up and run the Hand Gesture Control program on various operating systems (macOS, Linux, Windows).
- Python 3.7 or higher(Maximum at 3.10)
- pip (Python package manager)
- A working camera with proper permission granted
-
Clone the repository:
git clone https://github.com/bagaspra16/vision-python.git cd vision-python
-
Run the setup script:
bash setup.sh
Optional for Linux/macOS users:
chmod +x setup.sh && ./setup.sh
This script will:
- Create a virtual environment (
gesture_env
) - Activate the virtual environment
- Install all dependencies from
Requirements.txt
- Perform additional OS-specific setup (e.g., install
alsa-utils
on Linux)
- Create a virtual environment (
-
Activate the virtual environment (if not already):
-
macOS/Linux:
source gesture_env/bin/activate
-
Windows (Git Bash/PowerShell):
source gesture_env/Scripts/activate
-
-
Run the program:
python3 main.py
-
Create and activate the virtual environment:
python3 -m venv gesture_env source gesture_env/bin/activate # macOS/Linux # or source gesture_env/Scripts/activate # Windows
-
Install all dependencies:
pip install --upgrade pip pip install -r Requirements.txt
Once the program is running, you can control your computer using hand gestures in front of the camera:
- Open all fingers of the right hand: Open browser (YouTube)
- All fingers of right hand open: Move the mouse cursor
- Only the index finger extended: Left click
- Distance between both hands: Control volume (farther = increase, closer = decrease)
- Make a fist with the right hand for 5 seconds: Exit the program
- Move hand up/down on the screen: Auto-scroll the page
- Press 'q' key on keyboard: Quit the application
Notes:
- Make sure the camera is granted access in your OS settings.
- On Linux, ensure
alsa-utils
is installed for volume control to work. - On macOS, you may need to allow camera and input control access via System Preferences.
- If the camera is not detected, ensure it's not being used by another application.
- If gestures aren't responsive, ensure proper lighting and that your hand is clearly visible to the camera.
- For library-related errors, make sure all dependencies are installed in the virtual environment.
This program uses OpenCV, MediaPipe, pyautogui, and other libraries to detect hand gestures and control the computer cross-platform.