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.
- 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
- 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')
- 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
Python 3.7+
OpenCV 4.x
MediaPipe
NumPy
Tkinter (usually included with Python)
PyAutoGUIpip install opencv-python mediapipe numpy pyautogui# No additional setup required
python main.py# Grant accessibility permissions for PyAutoGUI
# System Preferences > Security & Privacy > Privacy > Accessibility
python main.py# Install additional dependencies
sudo apt-get install python3-tk
# May require sudo privileges for shutdown commands
python main.pypython main.py- Action: Move hand side-to-side repeatedly
- Requirements: 3+ direction changes with significant movement
- Cooldown: 2-second interval between detections
- Purpose: Initiates shutdown sequence
- Action: Show thumbs up with other fingers folded
- Timing: Must be performed within 10 seconds of wave detection
- Purpose: Confirms shutdown intent
- 'q': Quit application safely
- 'r': Reset system to idle state
- IDLE: Ready for wave detection (Green indicator)
- WAVE_DETECTED: Waiting for thumbs up confirmation (Yellow indicator)
- SHUTTING_DOWN: Normal shutdown sequence (Red indicator)
- TIMEOUT_SHUTDOWN: PyAutoGUI fallback shutdown (Orange indicator)
The main application class managing all system operations:
class GestureShutdownSystem:
def __init__(self):
# MediaPipe initialization
# State machine setup
# Gesture parameters configuration
# Visual feedback system- Idle State: Monitoring for wave gestures
- Detection State: Processing confirmation gestures
- Shutdown States: Managing shutdown sequences
- Camera Input: Real-time video capture
- Hand Detection: MediaPipe hand landmark extraction
- Gesture Analysis: Pattern recognition algorithms
- State Updates: State machine progression
- Visual Output: Annotated video display
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 resultdef detect_thumbs_up(self, hand_landmarks):
# Compares thumb and finger positions
# Validates thumb extension and finger folding
# Returns boolean thumbs up detection result- Two-Factor Gesture: Prevents single-gesture accidents
- Timeout Windows: Limited confirmation periods
- Movement Validation: Ensures deliberate gestures
- Safe Shutdown: Proper application closure before system shutdown
- Fallback Mechanisms: Multiple shutdown methods for reliability
- User Confirmation: Visual and audio feedback before shutdown
# Wave detection sensitivity
self.wave_threshold = 30
self.wave_count_required = 3
self.wave_cooldown = 2
# Confirmation timing
self.confirmation_timeout = 10# 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
}cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)# Check camera availability
python -c "import cv2; print(cv2.VideoCapture(0).isOpened())"# macOS: Enable accessibility permissions
# Linux: Run with sudo for shutdown commands
sudo python main.py- Ensure good lighting conditions
- Position hand clearly in camera view
- Perform gestures with deliberate movements
- Check MediaPipe detection confidence settings
- Verify OS compatibility
- Check system permissions
- Test PyAutoGUI fallback functionality
- Adjust camera resolution for performance
- Modify detection confidence thresholds
- Optimize gesture buffer sizes
- 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+
- Frame Rate: 30 FPS typical performance
- Detection Latency: <100ms gesture recognition
- Memory Usage: ~200MB runtime footprint
- CPU Usage: 15-25% on modern systems
git clone https://github.com/vijaybartaula/HandGestureShutdown.git
cd HandGestureShutdown
pip install -r requirements.txt
python -m pytest tests/- PEP 8 compliance for Python code
- Comprehensive docstrings for all methods
- Unit tests for core functionality
- Error handling for all external dependencies
- Submit issues for new gesture types
- Propose UI/UX improvements
- Suggest performance optimizations
- Report platform-specific bugs
This project is licensed under the MIT License - see the LICENSE file for details.
- MediaPipe Team: Hand tracking technology
- OpenCV Community: Computer vision framework
- Python Community: Core language and libraries