MediaPipe介绍
这个是真的,首先需要从Google在2020年发布的mediapipe开发包说起,这个开发包集成了人脸、眼睛、虹膜、手势、姿态等各种landmark检测与跟踪算法。
https://google.github.io/mediapipe/
请看下图比较详细
是个不折不扣的现实增强的宝藏工具包,特别实用!支持的平台跟语言也非常的丰富,图示如下:
只说一遍,感觉要逆天了,依赖库只有一个就是opencv,python版本的安装特别简单,直接运行下面的命令行:
pip install mediapipe
手势landmark检测
直接运行官方提供的Python演示程序,需要稍微修改一下,因为版本更新了,演示程序有点问题,改完之后执行运行视频测试,完美get到手势landmark关键点:
手势landmark的关键点编号与解释如下:
修改后的代码如下:
importcv2
importmediapipeasmp
mp_drawing=mp.solutions.drawing_utils
mp_hands=mp.solutions.hands
#Forwebcaminput:
cap=cv2.VideoCapture(0)
withmp_hands.Hands(
min_detection_confidence=0.5,
min_tracking_confidence=0.5)ashands:
whilecap.isOpened():
success,image=cap.read()
ifnotsuccess:
print("Ignoringemptycameraframe.")
#Ifloadingavideo,use'break'insteadof'continue'.
continue
#Toimproveperformance,optionallymarktheimageasnotwriteableto
#passbyreference.
image.flags.writeable=False
image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
results=hands.process(image)
#Drawthehandannotationsontheimage.
image.flags.writeable=True
image=cv2.cvtColor(image,cv2.COLOR_RGB2BGR)
ifresults.multi_hand_landmarks:
forhand_landmarksinresults.multi_hand_landmarks:
mp_drawing.draw_landmarks(
image,
hand_landmarks,
mp_hands.HAND_CONNECTIONS)
cv2.imwrite('D:/result.png',cv2.flip(image,1))
#Fliptheimagehorizontallyforaselfie-viewdisplay.
cv2.imshow('MediaPipeHands',cv2.flip(image,1))
ifcv2.waitKey(5)&0xFF==27:
break
cap.release()
手势识别
基于最简单的图象分类,收集了几百张图象,做了一个简单的迁移学习,实现了三种手势分类,运行请看视频:
-
手势识别
+关注
关注
8文章
219浏览量
47580 -
跟踪算法
+关注
关注
0文章
40浏览量
12984 -
OpenCV
+关注
关注
29文章
611浏览量
40786
原文标题:MediaPipe + OpenCV五分钟搞定手势识别
文章出处:【微信号:CVSCHOOL,微信公众号:OpenCV学堂】欢迎添加关注!文章转载请注明出处。
发布评论请先 登录
相关推荐
评论