Python_Interactive_somatosensory_operation:基于 MediaPipe 与 OpenCV 的手势控制虚拟键盘项目

交互性体感操控

Branch1Tags0

Gesture-Controlled Virtual Keyboard ✋⌨️

Python Version OpenCV Version

A gesture recognition system based on MediaPipe that controls a virtual keyboard by capturing hand movements via a camera.

🚀 Core Features

  • 3x3 Grid Direction Recognition: Precisely locates the palm's position within a 9-zone grid on the screen.
  • Gesture-to-Key Mapping: Customizable keyboard combinations mapped to 8 directions.
  • Long Press Trigger: Sustained gestures (1+ seconds) trigger special operations.
  • Fist Stop: Closing the fist immediately releases all active keys.
  • Mirror Mode: Supports switching between left and right hand usage.

🛠️ Technical Implementation

Key Algorithms

# Hand Region Judgment Logic
if wrist_x < third_width:
    if wrist_y < third_height: direction = "Top-Left"
    elif wrist_y < 2*third_height: direction = "Left"
    else: direction = "Bottom-Left"

Tech Stack

  • Hand Tracking: MediaPipe Hands
  • Image Processing: OpenCV
  • GUI Interface: Tkinter
  • Keyboard Simulation: keyboard library
  • Performance Optimization: Real-time processing at 60 FPS

📦 Installation & Usage

Install Dependencies

pip install opencv-python mediapipe keyboard pillow

Run Program

python main.py

🎮 Operation Guide

  1. Gesture Setup:

    • Click interface buttons to select a direction (e.g., "Top-Left").
    • Press physical keyboard keys to complete binding (up to 3-key combinations).
  2. Control Modes:

    • Move palm into the 3x3 grid area to trigger corresponding keys.
    • Hold gesture for 1 second to trigger long-press state.
    • Close fist to immediately stop all key inputs.
  3. Mirror Mode:

    • Click "Toggle Mirror Mode" button to adapt for left or right hand usage.

📂 Project Structure

Gesture_Keyboard/
├── main.py    # Main program
└── README.md

💡 Application Scenarios

  • Accessibility Assistance: Provides an input solution for individuals with mobility challenges.
  • Motion Gaming: Replaces controller directional pads for game control.
  • Presentation Control: Remotely control PPT slides.
  • Smart Home: Control smart devices via gestures.

🚨 Known Limitations

  • Requires good lighting conditions.
  • Complex backgrounds may affect recognition accuracy.
  • Currently supports single-hand input only.

Running Interface

image image ae7609f6b46fac18873184be4747b5f


⭐ If you like this project, please Star it for support!
🐛 Bug Reports: Please include environment configuration and error logs.

Introduction

交互性体感操控

Customize your domain