Skip to content

vijaybartaula/HandGestureShutdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Gesture Shutdown System

A sophisticated computer vision application that enables hands-free system shutdown through intuitive gesture recognition. Built with OpenCV and MediaPipe, this system provides a secure, contactless method for powering down computers using simple hand gestures.

Features

Core Functionality

  • Wave Detection: Detects horizontal hand waving motions to initiate shutdown sequence
  • Thumbs Up Confirmation: Requires thumbs up gesture for shutdown confirmation
  • Multi-Platform Support: Compatible with Windows, macOS, and Linux systems
  • Dual Shutdown Methods: Traditional OS commands with PyAutoGUI fallback
  • Real-time Visual Feedback: Live camera feed with gesture recognition overlay

Safety & Security

  • Two-Stage Authentication: Wave + thumbs up prevents accidental shutdowns
  • Timeout Protection: 10-second confirmation window with automatic fallback
  • Safe Shutdown Process: Graceful system shutdown with proper cleanup
  • Reset Capability: Manual system reset option (press 'r')

User Experience

  • Visual Status Indicators: Color-coded UI showing system state
  • Popup Notifications: System tray notifications for gesture events
  • Real-time FPS Display: Performance monitoring
  • Animated Feedback: Shutdown animations for visual confirmation

Installation

Prerequisites

Python 3.7+
OpenCV 4.x
MediaPipe
NumPy
Tkinter (usually included with Python)
PyAutoGUI

Install Dependencies

pip install opencv-python mediapipe numpy pyautogui

Platform-Specific Setup

Windows

# No additional setup required
python main.py

macOS

# Grant accessibility permissions for PyAutoGUI
# System Preferences > Security & Privacy > Privacy > Accessibility
python main.py

Linux

# Install additional dependencies
sudo apt-get install python3-tk
# May require sudo privileges for shutdown commands
python main.py

Usage

Starting the System

python main.py

Gesture Commands

1. Wave Gesture (Initiation)

  • Action: Move hand side-to-side repeatedly
  • Requirements: 3+ direction changes with significant movement
  • Cooldown: 2-second interval between detections
  • Purpose: Initiates shutdown sequence

2. Thumbs Up (Confirmation)

  • Action: Show thumbs up with other fingers folded
  • Timing: Must be performed within 10 seconds of wave detection
  • Purpose: Confirms shutdown intent

Keyboard Controls

  • 'q': Quit application safely
  • 'r': Reset system to idle state

System States

  1. IDLE: Ready for wave detection (Green indicator)
  2. WAVE_DETECTED: Waiting for thumbs up confirmation (Yellow indicator)
  3. SHUTTING_DOWN: Normal shutdown sequence (Red indicator)
  4. TIMEOUT_SHUTDOWN: PyAutoGUI fallback shutdown (Orange indicator)

πŸ—οΈ Architecture

Core Components

GestureShutdownSystem Class

The main application class managing all system operations:

class GestureShutdownSystem:
    def __init__(self):
        # MediaPipe initialization
        # State machine setup
        # Gesture parameters configuration
        # Visual feedback system

State Machine

  • Idle State: Monitoring for wave gestures
  • Detection State: Processing confirmation gestures
  • Shutdown States: Managing shutdown sequences

Computer Vision Pipeline

  1. Camera Input: Real-time video capture
  2. Hand Detection: MediaPipe hand landmark extraction
  3. Gesture Analysis: Pattern recognition algorithms
  4. State Updates: State machine progression
  5. Visual Output: Annotated video display

Gesture Recognition Algorithms

Wave Detection

def detect_wave_gesture(self, hand_landmarks):
    # Analyzes wrist position changes over time
    # Detects direction changes in hand movement
    # Validates movement amplitude and frequency
    # Returns boolean wave detection result

Thumbs Up Recognition

def detect_thumbs_up(self, hand_landmarks):
    # Compares thumb and finger positions
    # Validates thumb extension and finger folding
    # Returns boolean thumbs up detection result

πŸ›‘οΈ Security Features

Gesture Authentication

  • Two-Factor Gesture: Prevents single-gesture accidents
  • Timeout Windows: Limited confirmation periods
  • Movement Validation: Ensures deliberate gestures

System Protection

  • Safe Shutdown: Proper application closure before system shutdown
  • Fallback Mechanisms: Multiple shutdown methods for reliability
  • User Confirmation: Visual and audio feedback before shutdown

🎯 Configuration

Gesture Parameters

# Wave detection sensitivity
self.wave_threshold = 30
self.wave_count_required = 3
self.wave_cooldown = 2

# Confirmation timing
self.confirmation_timeout = 10

Visual Settings

# Color scheme customization
self.colors = {
    'green': (0, 255, 0),    # Ready state
    'yellow': (0, 255, 255), # Waiting confirmation
    'red': (0, 0, 255),      # Shutting down
    'orange': (0, 165, 255)  # Timeout shutdown
}

Camera Configuration

cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)

πŸ” Troubleshooting

Common Issues

Camera Not Detected

# Check camera availability
python -c "import cv2; print(cv2.VideoCapture(0).isOpened())"

Permission Errors (macOS/Linux)

# macOS: Enable accessibility permissions
# Linux: Run with sudo for shutdown commands
sudo python main.py

Gesture Not Recognized

  • Ensure good lighting conditions
  • Position hand clearly in camera view
  • Perform gestures with deliberate movements
  • Check MediaPipe detection confidence settings

Shutdown Commands Fail

  • Verify OS compatibility
  • Check system permissions
  • Test PyAutoGUI fallback functionality

Performance Optimization

  • Adjust camera resolution for performance
  • Modify detection confidence thresholds
  • Optimize gesture buffer sizes

πŸ“Š Performance Metrics

System Requirements

  • CPU: Multi-core processor recommended
  • RAM: 4GB minimum, 8GB recommended
  • Camera: USB webcam or integrated camera
  • OS: Windows 10+, macOS 10.14+, Ubuntu 18.04+

Benchmark Results

  • Frame Rate: 30 FPS typical performance
  • Detection Latency: <100ms gesture recognition
  • Memory Usage: ~200MB runtime footprint
  • CPU Usage: 15-25% on modern systems

🀝 Contributing

Development Setup

git clone https://github.com/vijaybartaula/HandGestureShutdown.git
cd HandGestureShutdown
pip install -r requirements.txt
python -m pytest tests/

Code Standards

  • PEP 8 compliance for Python code
  • Comprehensive docstrings for all methods
  • Unit tests for core functionality
  • Error handling for all external dependencies

Feature Requests

  • Submit issues for new gesture types
  • Propose UI/UX improvements
  • Suggest performance optimizations
  • Report platform-specific bugs

πŸ“œ License

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

πŸ™ Acknowledgments

  • MediaPipe Team: Hand tracking technology
  • OpenCV Community: Computer vision framework
  • Python Community: Core language and libraries

⚠️ Warning: This application can shut down your computer. Use responsibly and ensure all work is saved before testing. The system includes safety measures, but users should exercise caution during initial setup and testing phases.

About

A gesture recognition system that shuts down your computer using hand gestures (wave to start, thumbs up to confirm) with visual feedback and safety features.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages