python实现实时摄像头检测识别手势代码
代码语言:python
所属分类:其他
代码描述:python实现实时摄像头检测识别手势代码,可识别ok、握拳、剪刀、一、二、三手势。
代码标签: python 实时 摄像头 检测 识别 手势 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
#!/usr/local/python3/bin/python3 # -*- coding: utf-8 -* #pip install mediapipe #pip install pillow import cv2 import mediapipe as mp import math import numpy as np from PIL import Image, ImageDraw, ImageFont # 初始化MediaPipe mp_hands = mp.solutions.hands hands = mp_hands.Hands( static_image_mode=False, max_num_hands=2, min_detection_confidence=0.5, min_tracking_confidence=0.5 ) mp_draw = mp.solutions.drawing_utils # 打开摄像头 cap = cv2.VideoCapture(0) def cv2AddChineseText(img, text, position, textColor=(0, 255, 0), textSize=30): """ 在图片上添加中文文字 """ if (isinstance(img, np.ndarray)): # 判断是否OpenCV图片类型 img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) # 创建一个可以在图片上绘制的对象 draw = ImageDraw.Draw(im.........完整代码请登录后点击上方下载按钮下载查看
网友评论0