基于mediapipe库的python进行手势识别并且识别出数字
时间: 2024-06-13 21:09:46 浏览: 12
以下是基于mediapipe库的Python进行手势识别并且识别出数字的方法:
1. 首先,需要安装mediapipe库。可以使用以下命令进行安装:
```shell
pip install mediapipe
```
2. 然后,下载手势识别系统源码并运行project_mp.py文件。
3. 在运行过程中,系统会实时检测手部21个关键点,并根据手部关键点坐标计算五根手指的角度。
4. 最后,通过手指角度判断手势,例程中包含数字0~9的手势。
```python
# 判断数字手势
if is_finger_up(thumb, landmarks):
finger_number += 1
if is_finger_up(index, landmarks):
finger_number += 1
if is_finger_up(middle, landmarks):
finger_number += 1
if is_finger_up(ring, landmarks):
finger_number += 1
if is_finger_up(pinky, landmarks):
finger_number += 1
if finger_number == 0:
cv2.putText(image, "0", (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 255, 0), 2)
elif finger_number == 1:
cv2.putText(image, "1", (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 255, 0), 2)
elif finger_number == 2:
cv2.putText(image, "2", (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 255, 0), 2)
elif finger_number == 3:
cv2.putText(image, "3", (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 255, 0), 2)
elif finger_number == 4:
cv2.putText(image, "4", (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 255, 0), 2)
elif finger_number == 5:
cv2.putText(image, "5", (20, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 255, 0), 2)
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)