Project 6: Gesture-Controlled Presentation System
Control PowerPoint/PDF presentations using hand gestures - perfect for touchless presenting.
What You’ll Learn
- Hand Detection - Using MediaPipe
- Landmark Extraction - 21 hand keypoints
- Gesture Recognition - Finger states and movements
- Screen Automation - pyautogui integration
- Gesture Debouncing - Smooth interaction
Supported Gestures
| Gesture | Action |
|---|---|
| Swipe Left | Next slide |
| Swipe Right | Previous slide |
| Open Palm | Pause/Black screen |
| Fist | Resume |
| Thumbs Up | Volume up |
| Peace Sign | Volume down |
Usage
# Demo mode (visualization only)
python main.py --demo
# Full control mode
python main.py --control
Hand Landmarks
MediaPipe detects 21 landmarks per hand:
8 12 16 20
| | | |
4 7 11 15 19
| | | | |
3 6 10 14 18
| | | | |
2 5 9 13 17
| \ | / /
1 \|/ /
| 0---/
WRIST
Gesture Detection Logic
Finger State Detection
# Finger is extended if tip is above pip joint
is_extended = landmarks[tip]['y'] < landmarks[pip]['y']
Swipe Detection
# Track position history
# Detect significant horizontal movement
if abs(dx) > threshold:
return 'swipe_right' if dx > 0 else 'swipe_left'
Key Dependencies
| Library | Purpose |
|---|---|
| MediaPipe | Hand detection and landmarks |
| pyautogui | Keyboard/mouse automation |
| OpenCV | Image processing and display |
Code Highlights
Finger States
# Finger tip and pip (second joint) indices
tips = [4, 8, 12, 16, 20]
pips = [3, 6, 10, 14, 18]
# Check if tip is above pip (finger extended)
for tip, pip in zip(tips[1:], pips[1:]):
fingers.append(lm[tip]['y'] < lm[pip]['y'])
Gesture Cooldown
# Prevent repeated triggers
if current_time - last_action_time < cooldown:
return None # Skip this gesture
Real-World Applications
- Touchless presentations
- Accessibility interfaces
- Smart home control
- Gaming input
- Sign language recognition
Performance Tips
- Use
max_hands=1for better performance - Implement gesture cooldown
- Use position history for swipe detection
- Flip camera for mirror effect