概述
在本文中,我们将以深度库即 Mediapipe为基础库,以及其他计算机视觉预处理的CV2库来制作手部地标检测模型。市场上有很多关于这种问题的用例,例如商业相关的虚拟现实、游戏部分的实时体验。
![e70305c1c2f1c7e96fdc010a3ce4e4de.png](https://img-blog.csdnimg.cn/img_convert/e70305c1c2f1c7e96fdc010a3ce4e4de.png)
行业用例
智能家居:这是计算机视觉的现代用例之一,人们使用智能家居来过上更舒适的生活,这就是为什么它不再是一个小众领域,它也正在蔓延到普通家庭。
智能电视:我们经常看到这种用例,你可以用手势来改变音量、改变频道等等。
游戏:对于真正的体验,这项技术越来越多地融入互动游戏。
让我们建立我们的手部检测模型
导入库
在这里,我们将导入整个管道中需要的所有库。
import cv2
import numpy as np
import mediapipe as mp
import matplotlib.pyplot as plt
使用 Mediapipe 初始化手的地标检测模型
第一步是使用有效参数初始化模型,无论我们采用哪种检测技术,它可以是Mediapipe 或Yolo,初始化模型很重要,遵循相同的原则,我们将遵循所有给定的步骤:
# First step is to initialize the Hands class an store it in a variable
mp_hands = mp.solutions.hands
# Now second step is to set the hands function which will hold the landmarks points
hands = mp_hands.Hands(static_image_mode=True, max_num_hands=2, min_detection_confidence=0.3)
# Last step is to set up the drawing function of hands landmarks on the image
mp_drawing = mp.solutions.drawing_utils
代码分解:
首先,使用
mp.solutions