# ✋ Hand Tracking & Sign Language Recognition | 手势追踪与手语识别
A real-time hand tracking and sign language gesture recognition system built with **OpenCV** and **MediaPipe**.
基于 **OpenCV** 和 **MediaPipe** 的实时手势追踪与手语识别系统。
---
## 📖 Introduction | 项目简介
This project contains two Python programs:
本项目包含两个 Python 程序:
### `handtracking1.py` — Hand Tracking | 手部追踪
Captures video from your webcam and detects hand landmarks in real time. It draws 21 key points and connections on the detected hand, labels each landmark with its index, and displays the current FPS.
通过摄像头实时捕获视频并检测手部关键点。程序会在检测到的手上绘制 21 个关键点及其连接线,标注每个关键点的编号,并显示当前帧率(FPS)。
### `signlanguage111.py` — Sign Language Recognition | 手语识别
Recognizes hand gestures and maps them to numbers or symbols. It uses a convex hull algorithm to determine which fingers are raised, then classifies the gesture based on finger combinations and joint angles.
识别手势并将其映射为数字或符号。程序使用凸包算法判断哪些手指伸出,然后根据手指组合和关节角度对手势进行分类。
**Supported Gestures | 支持的手势:**
| Gesture 手势 | Meaning 含义 |
|:---:|:---:|
| ✊ | 10 |
| ☝️ (straight) | 1 |
| ☝️ (bent) | 9 |
| ✌️ | 2 |
| 🤟 (index + middle + ring) | 3 |
| 🖖 (four fingers) | 4 |
| 🖐 | 5 |
| 🤙 (thumb + pinky) | 6 |
| 👉 (thumb + index + middle) | 7 |
| 👌 (thumb + index) | 8 |
| 👍 (thumb only) | Good |
| 🤘 (thumb + index + pinky) | ROCK |
| 🔫 (thumb + index + middle, spread) | Gun |
---
## 🛠 Requirements | 环境依赖
- Python 3.7+
- OpenCV
- MediaPipe
- NumPy
---
## 📦 Installation | 安装
1. **Clone the repository | 克隆仓库**
```bash
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name- Install dependencies | 安装依赖
pip install opencv-python mediapipe numpypython handtracking1.pypython signlanguage111.pyPress q to quit the program.
按下 q 键退出程序。
The program uses MediaPipe's Hand solution to detect 21 hand landmarks from webcam input. Each landmark is drawn on the video frame with its index number, and hand connections are visualized using customized styles (red dots for landmarks, green lines for connections).
程序使用 MediaPipe 的手部检测模型从摄像头输入中检测 21 个手部关键点。每个关键点及其编号会绘制在视频帧上,手部连接线使用自定义样式可视化(红色圆点表示关键点,绿色线条表示连接)。
The recognition pipeline works in three steps:
手语识别流程分为三个步骤:
Step 1 — Convex Hull Construction | 构建凸包: A convex hull is built from selected palm landmarks (wrist, thumb base, and finger bases). This defines the "closed hand" boundary.
基于手掌关键点(手腕、拇指根部和各手指根部)构建凸包,定义"握拳"时的手部边界。
Step 2 — Finger Detection | 手指检测: Each fingertip (landmarks 4, 8, 12, 16, 20) is tested against the convex hull. If a fingertip falls outside the hull, that finger is considered "raised".
对每个指尖(关键点 4、8、12、16、20)进行凸包测试。如果指尖在凸包外部,则认为该手指"伸出"。
Step 3 — Gesture Classification | 手势分类: The combination of raised fingers is matched against predefined gesture patterns. For ambiguous cases (e.g., distinguishing "1" from "9"), joint angles or distance ratios are calculated for more precise classification.
根据伸出的手指组合匹配预定义的手势模式。对于容易混淆的情况(如区分"1"和"9"),通过计算关节角度或距离比值进行更精确的分类。
.
├── handtracking1.py # Hand landmark tracking with FPS display
├── signlanguage111.py # Sign language gesture recognition
├── README.md
└── requirements.txt # (optional) pip dependencies
Add your screenshots or GIFs here.
在此添加截图或 GIF 动图。
- A working webcam is required. | 需要可用的摄像头。
- For best results, use the program in a well-lit environment with a clean background. | 为获得最佳效果,请在光线充足、背景简洁的环境中使用。
- Currently only single-hand detection is supported in the sign language recognition module. | 手语识别模块目前仅支持单手检测。
This project is licensed under the MIT License.
本项目基于 MIT 许可证 开源。