Skip to content

rafiul254/AirControl-Pro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


Python OpenCV MediaPipe scikit-learn License Platform


Control your entire PC with just your hands. No mouse. No keyboard. Just gestures, voice, and AI.




๐Ÿ“Œ Table of Contents


๐Ÿง  About

AirControl Pro is a real-time, AI-powered desktop control system that lets you interact with your computer entirely through hand gestures, voice commands, and facial recognition โ€” no physical input device required.

Built from scratch using Python and computer vision, it goes beyond basic gesture detection by layering multiple AI systems together:

  • A face authentication gate that locks the system to the registered user
  • A multi-mode gesture engine powered by MediaPipe's 21-point hand landmark model
  • A trainable custom gesture AI using RandomForest that learns your own gestures
  • A live emotion detector that adapts the UI theme based on your expression
  • A background voice engine that accepts spoken commands alongside gestures

This project was designed and built as a real-world application of computer vision, machine learning, and human-computer interaction concepts.


โœจ Features

๐Ÿ” Face Authentication

  • LBPH-based face recognizer (OpenCV)
  • Locks system to registered user only
  • Runs fully offline โ€” no cloud, no API
  • Graceful fallback when no face is registered

๐Ÿ˜Š Emotion-Aware UI

  • Detects 5 facial expressions in real time
  • Dynamically changes HUD color theme
  • Smile + eye detection for accuracy
  • History-based smoothing to avoid flicker

๐Ÿค– Custom Gesture AI

  • Record your own gestures (50 samples each)
  • Trains a RandomForest classifier on your data
  • Model persists across sessions (.pkl file)
  • Live prediction confidence shown on HUD

๐ŸŽค Voice Command Engine

  • Background speech recognition (no hotword needed)
  • Controls modes, apps, and canvas via voice
  • Runs in a separate thread โ€” zero lag on main loop
  • Easily extendable with new commands

๐Ÿ–๏ธ Gesture Modes

Mode Switching

Gesture Mode Activated
โœŒ๏ธ Peace sign (2 fingers) ๐ŸŽต Media Mode
๐Ÿค™ Hang Loose ๐Ÿ–ฅ๏ธ System Mode
๐Ÿ–– 3 Fingers ๐ŸŽจ Draw Mode
๐Ÿค™ Hang Loose (inside Draw) โฌ…๏ธ Exit Draw Mode

๐ŸŽต Media Mode

Gesture Action
๐Ÿ‘Œ Thumb + Index pinch Volume control (distance-based)
โœ‹ Open Palm Play / Pause
โœŠ Fist Previous Track
๐Ÿค™ Pinky only Next Track

๐Ÿ–ฅ๏ธ System Mode

Gesture Action
โœ‹ Open Palm Take Screenshot
๐Ÿ‘Œ Thumb + Index pinch Brightness control
โœŠ Fist Alt + Tab
๐Ÿ–– 3 Fingers Show Desktop

๐ŸŽจ Draw Mode

Gesture Action
โ˜๏ธ 1 Finger Draw on canvas
โœŠ Fist Erase
โœ‹ Open Palm Clear entire canvas

๐Ÿ˜Š Emotion Themes

Emotion HUD Color Detection Logic
Happy ๐Ÿ˜Š Green Smile + eyes open
Neutral ๐Ÿ˜ Grey No smile, normal eyes
Focused ๐ŸŽฏ Blue Both eyes open, no smile
Surprised ๐Ÿ˜ฎ Cyan Wide eyes detected
Tired ๐Ÿ˜ด Purple Eyes closed / drooping

๐ŸŽค Voice Commands

Say Action
"media" Switch to Media Mode
"system" Switch to System Mode
"draw" Switch to Draw Mode
"youtube" Open YouTube in browser
"screenshot" Capture screenshot
"clear" Clear drawing canvas

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Camera Input                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ–ผ             โ–ผ             โ–ผ
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚ Face Engine โ”‚ โ”‚ Emotion  โ”‚ โ”‚ Voice Engine โ”‚
   โ”‚  (LBPH)     โ”‚ โ”‚ Detector โ”‚ โ”‚  (Thread)    โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ”‚             โ”‚              โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ–ผ
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚     Hand Tracker      โ”‚
            โ”‚  (MediaPipe 21-pt)    โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ–ผ
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚   Gesture Classifier  โ”‚
            โ”‚  Rule-based + AI (RF) โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ–ผ
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚      Mode Engine      โ”‚
            โ”‚  Mediaโ”‚Systemโ”‚Draw    โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ–ผ
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚    HUD Overlay        โ”‚
            โ”‚  Emotion-themed UI    โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Tech Stack

Technology Version Purpose
Python 3.11 Core language
OpenCV 4.10 Camera, image processing, face auth, emotion
MediaPipe 0.10 21-point hand landmark detection
scikit-learn 1.3 Custom gesture RandomForest classifier
PyAutoGUI latest Keyboard & mouse automation
pycaw latest Windows audio/volume control
SpeechRecognition latest Voice command processing
NumPy 2.x Numerical computations
joblib latest Model persistence

๐Ÿ“ Project Structure

AirControl-Pro/
โ”‚
โ”œโ”€โ”€ main.py                        # Entry point, main loop
โ”œโ”€โ”€ gesture_detector.py            # MediaPipe hand tracking
โ”œโ”€โ”€ gesture_classifier.py          # Rule-based gesture logic
โ”œโ”€โ”€ config.py                      # All settings & constants
โ”‚
โ”œโ”€โ”€ ai/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ custom_gesture_ai.py       # Trainable RandomForest AI
โ”‚   โ””โ”€โ”€ emotion_detector.py        # Facial emotion detection
โ”‚
โ”œโ”€โ”€ auth/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ face_auth.py               # LBPH face authentication
โ”‚
โ”œโ”€โ”€ voice/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ voice_engine.py            # Threaded speech recognition
โ”‚
โ”œโ”€โ”€ modes/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ media_mode.py              # Volume, play/pause, tracks
โ”‚   โ”œโ”€โ”€ system_mode.py             # Screenshot, brightness, apps
โ”‚   โ””โ”€โ”€ draw_mode.py               # Air drawing canvas
โ”‚
โ”œโ”€โ”€ hud/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ overlay.py                 # Emotion-themed HUD display
โ”‚
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ finger_counter.py          # Per-finger state detection
โ”‚   โ””โ”€โ”€ velocity_tracker.py        # Gesture speed tracking
โ”‚
โ””โ”€โ”€ data/
    โ”œโ”€โ”€ known_faces/             
    โ”‚   โ””โ”€โ”€ README.txt
    โ”œโ”€โ”€ gesture_samples.json       # Recorded training data (auto)
    โ””โ”€โ”€ gesture_model.pkl          # Trained model (auto)

๐Ÿš€ Getting Started

Prerequisites

  • Windows 10 or 11
  • Python 3.11
  • Webcam (built-in or external)
  • Microphone (for voice commands)

Installation

1. Clone the repository

git clone https://github.com/rafiul254/AirControl-Pro.git
cd AirControl-Pro

2. Create and activate virtual environment

python -m venv venv
.\venv\Scripts\Activate.ps1

3. Install all dependencies

pip install numpy
pip install opencv-contrib-python --only-binary=:all:
pip install mediapipe --only-binary=:all:
pip install protobuf --only-binary=:all:
pip install scikit-learn joblib
pip install pyautogui
pip install pycaw comtypes
pip install screen-brightness-control
pip install SpeechRecognition pyaudio

4. Register your face

Add a clear, front-facing photo of yourself:

data/known_faces/YourName.jpg

5. Run

python main.py

๐ŸŽฎ How to Use

Keyboard Shortcuts

Key Action
Q Quit
F Toggle fullscreen
R Start recording a custom gesture
T Train the custom gesture AI

Tips for Best Results

โœ…  Stay 30โ€“60 cm from the camera
โœ…  Keep your hand fully visible in frame
โœ…  Use in a well-lit environment
โœ…  Keep hand to the side โ€” not in front of your face
โœ…  Hold gestures steady for ~1 second to trigger

๐Ÿค– Training Custom Gestures

You can teach AirControl Pro any hand sign you want:

Step 1 โ€” Run the app: python main.py
Step 2 โ€” Press R
Step 3 โ€” Type a name for your gesture (e.g. "thumbs_up")
Step 4 โ€” Hold the gesture in front of the camera
         (50 samples will be captured automatically)
Step 5 โ€” Repeat for at least 2 different gestures
Step 6 โ€” Press T to train the AI
Step 7 โ€” Your model saves to data/gesture_model.pkl
         and auto-loads next time you run the app

โš™๏ธ Configuration

Edit config.py to customize behavior:

CAMERA_ID             = 0      # Change if using external camera
FRAME_WIDTH           = 640
FRAME_HEIGHT          = 480
DETECTION_CONFIDENCE  = 0.5    # Lower = detects more, less accurate
GESTURE_HOLD_TIME     = 0.8    # Seconds to confirm a gesture
MODE_SWITCH_COOLDOWN  = 1.5    # Seconds between mode switches
MAX_HANDS             = 1

๐Ÿ—บ๏ธ Roadmap

  • [complete] Multi-mode gesture control (Media, System, Draw)
  • [complete] Face authentication with LBPH
  • [complete] Emotion-aware adaptive UI
  • [complete] Custom gesture AI (RandomForest)
  • [complete] Threaded voice command engine
  • [complete] Live HUD with FPS, mode, emotion display
  • [In future] Browser control mode (scroll, tab switch)
  • [In future] Virtual air keyboard
  • [In future] IoT integration via MQTT (GestureBot)
  • [In future] Multi-user face profile support
  • [In future] Gesture macro recorder

๐Ÿ‘จโ€๐Ÿ’ป Author

MD. Rafiul Islam

IoT & Robotics Engineering | University of Frontier Technology, Bangladesh


GitHub LinkedIn


๐Ÿ“„ License

This project is licensed under the MIT License โ€” see LICENSE for details.


If this project helped or inspired you, consider leaving a โญ star in this repo