Air Mouse is an innovative human-computer interaction project that combines motion sensing and gesture recognition to create a natural and intuitive way to control your computer. The project consists of two main components:
- A hardware controller using ESP32 and MPU6050 for motion-based cursor control
- A computer vision system using OpenCV and MediaPipe for hand gesture recognition
This combination allows users to control their computer through natural hand movements and gestures, creating an immersive and intuitive interaction experience.
-
Motion-Based Cursor Control
- Precise cursor movement using gyroscope and accelerometer data
- Complementary filter for smooth motion tracking
- Moving average filter to reduce noise
- Bluetooth connectivity for wireless operation
-
Gesture Recognition
- Index finger pinch: Left mouse click and drag
- Middle finger pinch: Right mouse click
- Ring finger pinch: Scroll down
- Pinky finger pinch: Scroll up
- Real-time hand tracking and visualization
- ESP32 microcontroller
- MPU6050 6-axis IMU (accelerometer + gyroscope)
- USB cable for programming
- Power source (battery or USB)
- Arduino IDE
- Python 3.x
- Required Python packages:
opencv-python mediapipe pyautogui - Required Arduino libraries:
Wire.h MPU6050_tockn.h BleKeyboard.h
- Connect the MPU6050 to ESP32:
- VCC → 3.3V
- GND → GND
- SDA → GPIO21
- SCL → GPIO22
- Install the Arduino IDE
- Add ESP32 board support to Arduino IDE
- Install required libraries through Arduino Library Manager
- Upload the
esp32code.inoto your ESP32
- Install required Python packages:
pip install opencv-python mediapipe pyautogui
- Run the gesture recognition script:
python main.py
- Power on the ESP32 device
- Connect to the ESP32 through Bluetooth (it will appear as "ESP32 Virtual Mouse")
- Launch the Python script for gesture recognition
- Hold your hand in front of the camera
- Use the following gestures:
- Move the ESP32 device to control cursor position
- Pinch index finger and thumb for left click/drag
- Pinch middle finger and thumb for right click
- Pinch ring finger and thumb for scrolling down
- Pinch pinky finger and thumb for scrolling up
- Uses complementary filter to combine accelerometer and gyroscope data
- Implements moving average filter for noise reduction
- Bluetooth communication using BleKeyboard library
- Adjustable sensitivity and filter parameters
- Hand landmark detection using MediaPipe
- Real-time finger tracking and gesture recognition
- Multi-threaded scroll functionality
- Configurable pinch threshold
- Adjust
sensitivityvariable in ESP32 code to modify cursor movement speed - Modify
PINCH_THRESHOLDin Python script to change gesture sensitivity - Change
FILTER_WINDOWsize in ESP32 code to adjust motion smoothing - Customize gesture actions by modifying the gesture detection logic
- No Bluetooth Connection: Ensure ESP32 is powered and in range
- Erratic Cursor Movement: Adjust sensitivity and filter parameters
- Gesture Not Detected: Check camera and lighting conditions
- Delayed Response: Verify system resources and USB camera connection
Feel free to fork this project and submit pull requests with improvements. Some areas for potential enhancement:
- Additional gesture support
- Improved motion filtering algorithms
- Battery optimization for ESP32
- Custom gesture mapping interface
This project is released under the MIT License. See LICENSE file for details.
- MediaPipe team for their hand tracking solution
- MPU6050_tockn library developers
- ESP32 BleKeyboard library contributors