Skip to content

lakshyakhandelwal2901/python-based-hand-tracking-application-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hand Tracking Gesture Control

A real-time hand-tracking project built using OpenCV, MediaPipe, and Python. This system uses your webcam to detect hand landmarks and perform actions like:

  • Volume Control (thumb–index distance)
  • Zoom Simulation (digital zoom effect via pinch gesture)
  • Drawing Mode (index finger tracking)
  • Can be extended with more gestures

Features

  • Real-time hand landmark detection using MediaPipe (21 points on each hand).
  • Modular design with separate files:
    • main.py → Entry point for the app
    • hand_tracking.py → Handles camera & landmark detection
    • gestures.py → Defines custom gestures (volume, zoom, drawing, etc.)
  • Easy to extend: Add new gestures with just a function!
  • Cross-platform (Windows/Linux/Mac) — OS-specific volume control included.

Project Structure

📦 hand-tracking-gesture-control
├── main.py            # Main script (runs the system)
├── hand_tracking.py   # HandTracker class (camera + mediapipe processing)
├── gestures.py        # Gesture functions (volume, zoom, draw, etc.)
├── requirements.txt   # Python dependencies
└── README.txt         # Documentation (this file)

Installation

  1. Clone the repository:
git clone https://github.com/your-username/hand-tracking-gesture-control.git
cd hand-tracking-gesture-control
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the project:
python main.py

Requirements

Your requirements.txt should contain:

opencv-python
mediapipe
numpy
pycaw   # (for Windows volume control)

Landmark IDs Reference

MediaPipe uses 21 hand landmarks:

ID Landmark Description
0 Wrist Base of palm
1-4 Thumb joints CMC → MCP → IP → Tip
5-8 Index finger MCP → PIP → DIP → Tip
9-12 Middle finger MCP → PIP → DIP → Tip
13-16 Ring finger MCP → PIP → DIP → Tip
17-20 Pinky finger MCP → PIP → DIP → Tip
hand_landmarks_diagram

📌 Example:

  • 4 → Thumb Tip
  • 8 → Index Tip
  • These two are used for pinch gestures (zoom/volume control).

How It Works

  1. OpenCV captures webcam frames.
  2. MediaPipe processes frames to detect 21 landmarks per hand.
  3. Gestures are recognized by measuring distances between key landmarks.
  4. Actions are triggered:
    • Volume Control: Distance between thumb tip (4) and index tip (8).
    • Zoom: Pinch distance mapped to digital zoom effect.
    • Draw: Tracks index tip (8) on the canvas.

Demo (Screenshots / GIFs)

Screenshot 2025-09-20 034045 Screenshot 2025-09-20 034122 Screenshot 2025-09-20 034213

Future Improvements

  • Multi-hand gesture support
  • Gesture recognition with ML model (custom gestures)
  • System-level integration (brightness, media control, etc.)
  • Export as a desktop app with PyInstaller

Contributing

Feel free to fork this project, open issues, and submit pull requests.

About

In this repo, we’ll walk through a hands-on demonstration of how simple it is to track your hand in Python using the MediaPipe package. As a result, you’ll be able to control your computer’s volume without even touching it! I’m not sure what else to say if this doesn’t sound like magic.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages