Skip to content

AkshayS734/Virtual-Mouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ–ฑ๏ธ Virtual Mouse

Control your computer with hand gestures using computer vision

Python Version License: MIT Platform

Virtual Mouse is a computer vision project that lets you control your mouse cursor and perform various actions using simple hand gestures. No need for a physical mouse - just use your webcam and hand movements!

โœจ Features

  • ๐ŸŽฏ Precise cursor control with hand tracking
  • ๐Ÿ‘† Multiple gesture support (click, right-click, scroll, drag)
  • ๐Ÿ”ง Auto-calibration adapts to your hand size
  • ๐Ÿš€ Real-time processing with smooth performance
  • ๐Ÿ›ก๏ธ Error handling with graceful failure recovery
  • โš™๏ธ Configurable settings for personalization
  • ๐Ÿ“ฑ Cross-platform support (Windows, macOS, Linux)

๏ฟฝ Gesture Controls

Gesture Action How to Perform
๐Ÿ‘Œ Pinch Left Click Touch thumb and index finger together
โœŒ๏ธ Peace Sign Right Click Show index and middle fingers only
๐ŸคŸ Three Fingers Scroll Up Extend index, middle, and ring fingers
๐Ÿ–๏ธ Four Fingers Scroll Down Extend all fingers except thumb
โœŠ Closed Fist Drag Make a fist to drag objects
๐Ÿ–๏ธ Open Hand Screenshot Show all five fingers

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.7 or higher
  • Webcam
  • Good lighting conditions

Installation

  1. Clone the repository

    git clone https://github.com/AkshayS734/virtual-mouse.git
    cd virtual-mouse
  2. Create a virtual environment (recommended)

    python -m venv venv
    
    # On Windows
    venv\Scripts\activate
    
    # On macOS/Linux
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Run the application

    python main.py

That's it! Your webcam should open and you can start controlling your mouse with hand gestures.

๏ฟฝ System Requirements

Minimum Requirements

  • CPU: Dual-core processor
  • RAM: 4GB
  • Camera: Any USB webcam or built-in camera
  • OS: Windows 7+, macOS 10.12+, or Linux

Recommended

  • CPU: Quad-core processor
  • RAM: 8GB
  • Camera: HD webcam for better accuracy
  • Lighting: Well-lit environment

๐ŸŽฏ Usage Guide

First Time Setup

  1. Position yourself: Sit 1-2 feet away from your camera
  2. Check lighting: Ensure your hand is well-lit
  3. Start the app: Run python main.py
  4. Calibrate: The app will automatically adjust to your hand size

Basic Usage

  1. Move cursor: Point with your index finger
  2. Click: Make a pinch gesture (thumb + index)
  3. Right-click: Show peace sign (index + middle)
  4. Scroll: Use three fingers (up) or four fingers (down)
  5. Drag: Make a fist and move your hand
  6. Screenshot: Show all five fingers

Keyboard Controls

  • Q: Quit the application
  • R: Reset hand calibration

Tips for Best Performance

  • ๐Ÿ”† Use good lighting
  • ๐Ÿ“ Stay 1-2 feet from camera
  • ๐Ÿคš Make clear, distinct gestures
  • โฑ๏ธ Hold gestures for 1-2 seconds
  • ๐Ÿ”„ Press 'R' if gestures aren't recognized

โš™๏ธ Configuration

You can customize the app by editing config.py:

# Gesture sensitivity (0.1 to 1.0)
GESTURE_CONFIDENCE_THRESHOLD = 0.8

# Cursor smoothing (0 = no smoothing, 1 = max smoothing)
CURSOR_SMOOTHING_FACTOR = 0.3

# Camera settings
CAMERA_INDEX = 0  # Change if you have multiple cameras
FLIP_HORIZONTAL = True  # Mirror the video feed

๐Ÿ”ง Troubleshooting

Common Issues

Camera not working?

  • Check if other apps are using the camera
  • Try changing CAMERA_INDEX in config.py (0, 1, 2...)
  • Restart the application

Gestures not detected?

  • Ensure good lighting
  • Move closer or farther from camera
  • Press 'R' to reset calibration
  • Make gestures more distinct

App running slowly?

  • Close other heavy applications
  • Lower the camera resolution in config.py
  • Check your internet connection isn't being used by other apps

Permission errors on macOS?

  • Go to System Preferences โ†’ Security & Privacy โ†’ Camera
  • Enable camera access for Terminal/Python
  • Do the same for Accessibility if needed

Debug Mode

Enable detailed logging:

# In config.py
LOG_LEVEL = 'DEBUG'
SHOW_DEBUG_INFO = True

๐Ÿ—๏ธ Project Structure

virtual-mouse/
โ”œโ”€โ”€ .gitignore               # Git ignore rules
โ”œโ”€โ”€ main.py                  # Main application (start here!)
โ”œโ”€โ”€ virtual_mouse_modular.py # Alternative modular version
โ”œโ”€โ”€ config.py                # Configuration settings
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ LICENSE                  # MIT License
โ”œโ”€โ”€ README.md                # You are here
โ”œโ”€โ”€ gestures/
โ”‚   โ”œโ”€โ”€ __init__.py         # Package initialization
โ”‚   โ””โ”€โ”€ gesture_utils.py    # Gesture detection logic
โ”œโ”€โ”€ screenshots/            # Auto-created for screenshots
โ””โ”€โ”€ tests/                  # Unit tests

๐Ÿงช Running Tests

# Run all tests
python -m pytest tests/

# Run specific test files
python tests/test_fixes.py

# Verify bug fixes
python tests/verify_fixes.py

# Check import compatibility
python tests/check_imports.py

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Test your changes: python -m pytest
  5. Commit: git commit -am 'Add new feature'
  6. Push: git push origin feature-name
  7. Submit a Pull Request

Development Setup

# Install dependencies
pip install -r requirements.txt

# Optional: Install development tools
pip install pylint black flake8 mypy

# Run code formatting (if tools installed)
black .
flake8 .

๐Ÿ“Š Performance

Metric Value
Accuracy ~85% gesture recognition
Latency ~100ms response time
FPS 30 FPS video processing
CPU Usage ~15-25% on modern hardware

๐Ÿ”ฎ Roadmap

  • Multi-hand support for advanced gestures
  • Gesture customization interface
  • Voice command integration
  • Mobile app for remote control
  • AI-powered gesture learning
  • Eye tracking integration

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • MediaPipe - Google's ML framework for hand tracking
  • OpenCV - Computer vision library
  • PyAutoGUI - Cross-platform GUI automation

โญ Support

If you find this project helpful, please consider:

  • โญ Starring the repository
  • ๐Ÿ› Reporting bugs via GitHub Issues
  • ๏ฟฝ Suggesting features via GitHub Discussions
  • ๐Ÿค Contributing code or documentation

๐Ÿ“ž Contact


Made with โค๏ธ for accessible computing

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages