资源简介
OpenCV+python手势识别框架和简单例子 基于 静默虚空 大神文章的原码修改调通的。https://blog.csdn.net/linsk/article/details/76457955
代码片段和文件信息
#!/usr/bin/python
import math
import numpy as np
class Gesture(object):
def __init__(selfname):
self.name=name
def getName(self):
return self.name
def set_palm(selfhand_centerhand_radius):
self.hand_center=hand_center
self.hand_radius=hand_radius
def set_finger_pos(selffinger_pos):
self.finger_pos=finger_pos
self.finger_count=len(finger_pos)
def calc_angles(self):
self.angle=np.zeros(self.finger_countdtype=int)
for i in range(self.finger_count):
y = self.finger_pos[i][1]
x = self.finger_pos[i][0]
self.angle[i]=abs(math.atan2((self.hand_center[1]-y)(x-self.hand_center[0]))*180/math.pi)
def DefineGestures():
dict={}
# 1. BEGIN ------------------------------------#
V=Gesture(“V“)
V.set_palm((475225)45)
V.set_finger_pos([(49090)(415105)])
V.calc_angles()
dict[V.getName()]=V
# 1. END --------------------------------------#
# 2. BEGIN ------------------------------------#
L_right=Gesture(“L_right“)
L_right.set_palm((475225)50)
L_right.set_finger_pos([(45062)(345200)])
L_right.calc_angles()
dict[L_right.getName()]=L_right
# 2. END --------------------------------------#
# 3. BEGIN ------------------------------------#
Index_Pointing=Gesture(“Index_Pointing“)
Index_Pointing.set_palm((480230)43)
Index_Pointing.set_finger_pos([(475102)])
Index_Pointing.calc_angles()
dict[Index_Pointing.getName()]=Index_Pointing
# 3. END --------------------------------------#
return dict
def CompareGestures(src1src2):
if(src1.finger_count==src2.finger_count):
if(src1.finger_count==1):
angle_diff=src1.angle[0]-src2.angle[0]
if(angle_diff>20):
result=0
else:
len1 = np.sqrt((src1.finger_pos[0][0]- src1.hand_center[0])**2 + (src1.finger_pos[0][1] - src1.hand_center[1])**2)
len2 = np.sqrt((src2.finger_pos[0][0]- src2.hand_center[0])**2 + (src2.finger_pos[0][1] - src2.hand_center[1])**2)
length_diff=len1/len2
radius_diff=src1.hand_radius/src2.hand_radius
length_score=abs(length_diff-radius_diff)
if(length_score<0.09):
result=src2.getName()
else:
result=0
else:
angle_diff=[]
for i in range(src1.finger_count):
angle_diff.append(src1.angle[i]-src2.angle[i])
angle_score=max(angle_diff)-min(angle_diff)
if(angle_score<15):
length_diff=[]
for i in range(src1.finger_count):
len1 = np.sqrt((src1.finger_pos[i][0]- src1.hand_center[0])**2 + (src1.finger_pos[i][1] - src1.hand_center[1])**2)
len2 = np.sqrt((src2.finger_pos[i][0]- src2.hand_center[0])**2 + (src2.finger_pos[i][1] - src2.hand_center[1])**2)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-04-15 15:21 hand-gesture-recognition-opencv-master\
文件 3579 2016-07-02 09:04 hand-gesture-recognition-opencv-master\GestureAPI.py
目录 0 2019-04-15 16:00 __MACOSX\
目录 0 2019-04-15 16:00 __MACOSX\hand-gesture-recognition-opencv-master\
文件 268 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\._GestureAPI.py
目录 0 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\
文件 182529 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\8.jpg
目录 0 2019-04-15 16:00 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\
文件 212 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._8.jpg
文件 179163 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\9.jpg
文件 212 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._9.jpg
文件 174660 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\4.jpg
文件 268 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._4.jpg
文件 111111 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\5.jpg
文件 268 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._5.jpg
文件 182413 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\7.jpg
文件 212 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._7.jpg
文件 44299 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\6.jpg
文件 212 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._6.jpg
文件 50359 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\2.jpg
文件 268 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._2.jpg
文件 198452 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\3.jpg
文件 268 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._3.jpg
文件 179617 2016-07-02 09:04 hand-gesture-recognition-opencv-master\screenshots\1.jpg
文件 268 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\screenshots\._1.jpg
文件 212 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\._screenshots
文件 6148 2019-04-15 15:27 hand-gesture-recognition-opencv-master\.DS_Store
文件 120 2019-04-15 15:27 __MACOSX\hand-gesture-recognition-opencv-master\._.DS_Store
文件 1081 2016-07-02 09:04 hand-gesture-recognition-opencv-master\LICENSE
文件 212 2016-07-02 09:04 __MACOSX\hand-gesture-recognition-opencv-master\._LICENSE
目录 0 2019-04-15 14:40 hand-gesture-recognition-opencv-master\__pycache__\
............此处省略18个文件信息
评论
共有 条评论