OpenCV+Python3.5 简易手势识别任务
检测剪刀石头布三种手势,通过摄像头输入,方法如下:
选用合适颜色空间及阈值提取皮肤部分
使用滤波腐蚀膨胀等方法去噪
边缘检测
寻用合适方法分类
OpenCV用摄像头捕获视频
采用方法:调用OpenCV——cv2.VideoCapture()
def video_capture(): cap = cv2.VideoCapture(0) while True: # capture frame-by-frame ret, frame = cap.read() # our operation on the frame come here # gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 可选择灰度化 # display the resulting frame cv2.imshow('frame', frame) if cv2.waitKey(1) & 0xFF == ord('q'): # 按q键退出 break # when everything done , release the capture cap.release() cv2.destroyAllWindows()1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
效果如下