当前位置: 首页 > news >正文

广西网站建设价格网站seo收录工具

广西网站建设价格,网站seo收录工具,新鸿儒做网站,自在源码网官网【精选】【优秀课设】基于OpenCVMediaPipe的手势识别(数字、石头剪刀布等手势识别)_石头剪刀布opencv识别代码_网易独家音乐人Mike Zhou的博客-CSDN博客 import cv2 import mediapipe as mp import mathdef vector_2d_angle(v1, v2):求解二维向量的角度v…

【精选】【优秀课设】基于OpenCV+MediaPipe的手势识别(数字、石头剪刀布等手势识别)_石头剪刀布opencv识别代码_网易独家音乐人Mike Zhou的博客-CSDN博客

import cv2
import mediapipe as mp
import mathdef vector_2d_angle(v1, v2):'''求解二维向量的角度'''v1_x = v1[0]v1_y = v1[1]v2_x = v2[0]v2_y = v2[1]try:angle_ = math.degrees(math.acos((v1_x * v2_x + v1_y * v2_y) / (((v1_x ** 2 + v1_y ** 2) ** 0.5) * ((v2_x ** 2 + v2_y ** 2) ** 0.5))))except:angle_ = 65535.if angle_ > 180.:angle_ = 65535.return angle_def hand_angle(hand_):'''获取对应手相关向量的二维角度,根据角度确定手势'''angle_list = []# ---------------------------- thumb 大拇指角度angle_ = vector_2d_angle(((int(hand_[0][0]) - int(hand_[2][0])), (int(hand_[0][1]) - int(hand_[2][1]))),((int(hand_[3][0]) - int(hand_[4][0])), (int(hand_[3][1]) - int(hand_[4][1]))))angle_list.append(angle_)# ---------------------------- index 食指角度angle_ = vector_2d_angle(((int(hand_[0][0]) - int(hand_[6][0])), (int(hand_[0][1]) - int(hand_[6][1]))),((int(hand_[7][0]) - int(hand_[8][0])), (int(hand_[7][1]) - int(hand_[8][1]))))angle_list.append(angle_)# ---------------------------- middle 中指角度angle_ = vector_2d_angle(((int(hand_[0][0]) - int(hand_[10][0])), (int(hand_[0][1]) - int(hand_[10][1]))),((int(hand_[11][0]) - int(hand_[12][0])), (int(hand_[11][1]) - int(hand_[12][1]))))angle_list.append(angle_)# ---------------------------- ring 无名指角度angle_ = vector_2d_angle(((int(hand_[0][0]) - int(hand_[14][0])), (int(hand_[0][1]) - int(hand_[14][1]))),((int(hand_[15][0]) - int(hand_[16][0])), (int(hand_[15][1]) - int(hand_[16][1]))))angle_list.append(angle_)# ---------------------------- pink 小拇指角度angle_ = vector_2d_angle(((int(hand_[0][0]) - int(hand_[18][0])), (int(hand_[0][1]) - int(hand_[18][1]))),((int(hand_[19][0]) - int(hand_[20][0])), (int(hand_[19][1]) - int(hand_[20][1]))))angle_list.append(angle_)return angle_listdef h_gesture(angle_list):'''# 二维约束的方法定义手势# fist five gun love one six three thumbup yeah'''thr_angle = 65.  # 手指闭合则大于这个值(大拇指除外)thr_angle_thumb = 53.  # 大拇指闭合则大于这个值thr_angle_s = 49.  # 手指张开则小于这个值gesture_str = "Unknown"if 65535. not in angle_list:if (angle_list[0] > thr_angle_thumb) and (angle_list[1] > thr_angle) and (angle_list[2] > thr_angle) and (angle_list[3] > thr_angle) and (angle_list[4] > thr_angle):gesture_str = "0"elif (angle_list[0] > thr_angle_thumb) and (angle_list[1] < thr_angle_s) and (angle_list[2] > thr_angle) and (angle_list[3] > thr_angle) and (angle_list[4] > thr_angle):gesture_str = "1"elif (angle_list[0] > thr_angle_thumb) and (angle_list[1] < thr_angle_s) and (angle_list[2] < thr_angle_s) and (angle_list[3] > thr_angle) and (angle_list[4] > thr_angle):gesture_str = "2"elif (angle_list[0] > thr_angle_thumb) and (angle_list[1] < thr_angle_s) and (angle_list[2] < thr_angle_s) and (angle_list[3] < thr_angle_s) and (angle_list[4] > thr_angle):gesture_str = "3"elif (angle_list[0] > thr_angle_thumb) and (angle_list[1] < thr_angle_s) and (angle_list[2] < thr_angle_s) and (angle_list[3] < thr_angle_s) and (angle_list[4] < thr_angle_s):gesture_str = "4"elif (angle_list[0] < thr_angle_s) and (angle_list[1] < thr_angle_s) and (angle_list[2] < thr_angle_s) and (angle_list[3] < thr_angle_s) and (angle_list[4] < thr_angle_s):gesture_str = "5"elif (angle_list[0] < thr_angle_s) and (angle_list[1] > thr_angle) and (angle_list[2] > thr_angle) and (angle_list[3] > thr_angle) and (angle_list[4] < thr_angle_s):gesture_str = "6"elif (angle_list[0] < thr_angle_s) and (angle_list[1] < thr_angle_s) and (angle_list[2] > thr_angle) and (angle_list[3] > thr_angle) and (angle_list[4] > thr_angle):gesture_str = "8"elif (angle_list[0] > thr_angle_thumb) and (angle_list[1] > thr_angle) and (angle_list[2] > thr_angle) and (angle_list[3] > thr_angle) and (angle_list[4] < thr_angle_s):gesture_str = "Pink Up"elif (angle_list[0] < thr_angle_s) and (angle_list[1] > thr_angle) and (angle_list[2] > thr_angle) and (angle_list[3] > thr_angle) and (angle_list[4] > thr_angle):gesture_str = "Thumb Up"elif (angle_list[0] > thr_angle_thumb) and (angle_list[1] > thr_angle) and (angle_list[2] < thr_angle_s) and (angle_list[3] > thr_angle) and (angle_list[4] > thr_angle):gesture_str = "Fuck"elif (angle_list[0] > thr_angle_thumb) and (angle_list[1] > thr_angle) and (angle_list[2] < thr_angle_s) and (angle_list[3] < thr_angle_s) and (angle_list[4] < thr_angle_s):gesture_str = "Princess"elif (angle_list[0] < thr_angle_s) and (angle_list[1] < thr_angle_s) and (angle_list[2] < thr_angle_s) and (angle_list[3] > thr_angle) and (angle_list[4] > thr_angle):gesture_str = "Bye"elif (angle_list[0] < thr_angle_s) and (angle_list[1] < thr_angle_s) and (angle_list[2] > thr_angle) and (angle_list[3] > thr_angle) and (angle_list[4] < thr_angle_s):gesture_str = "Spider-Man"elif (angle_list[0] > thr_angle_thumb) and (angle_list[1] < thr_angle_s) and (angle_list[2] > thr_angle) and (angle_list[3] > thr_angle) and (angle_list[4] < thr_angle_s):gesture_str = "Rock'n'Roll"return gesture_strdef detect():mp_drawing = mp.solutions.drawing_utilsmp_hands = mp.solutions.handshands = mp_hands.Hands(static_image_mode=False,max_num_hands=1,min_detection_confidence=0.75,min_tracking_confidence=0.75)cap = cv2.VideoCapture(0)while True:ret, frame = cap.read()frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)frame = cv2.flip(frame, 1)results = hands.process(frame)frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)if results.multi_handedness:for hand_label in results.multi_handedness:hand_jugg = str(hand_label).split('"')[1]print(hand_jugg)cv2.putText(frame, hand_jugg, (50, 200), 0, 1.3, (0, 0, 255), 2)if results.multi_hand_landmarks:for hand_landmarks in results.multi_hand_landmarks:mp_drawing.draw_landmarks(frame, hand_landmarks, mp_hands.HAND_CONNECTIONS)hand_local = []for i in range(21):x = hand_landmarks.landmark[i].x * frame.shape[1]y = hand_landmarks.landmark[i].y * frame.shape[0]hand_local.append((x, y))if hand_local:angle_list = hand_angle(hand_local)gesture_str = h_gesture(angle_list)print(gesture_str)cv2.putText(frame, gesture_str, (50, 100), 0, 1.3, (0, 0, 255), 2)cv2.imshow('MediaPipe Hands', frame)if cv2.waitKey(1) & 0xFF == 27:breakcap.release()cv2.destroyAllWindows()if __name__ == '__main__':detect()

代码的解释请参考

【精选】【优秀课设】基于OpenCV+MediaPipe的手势识别(数字、石头剪刀布等手势识别)_石头剪刀布opencv识别代码_网易独家音乐人Mike Zhou的博客-CSDN博客

http://www.jinmujx.cn/news/115746.html

相关文章:

  • 免费网站建设站重庆seo网站排名
  • 手机端什么可以替代迅雷廊坊百度提升优化
  • 网站建设代码容易出错石家庄seo外包的公司
  • 湖北智能网站建设找哪家媒体代发网站
  • 电子商务网站名字百度大数据分析平台
  • 惠州网站建设一般多少钱网页设计一般用什么软件
  • 百度推广 网站建设奶茶软文案例300字
  • 网站前端切图做多个页面seo快速排名软件首页
  • WordPress邮箱验证登录seo外链平台热狗
  • 秦皇岛北京网站建设百度推广开户联系方式
  • 手机微网站建设太原seo推广
  • 湖南网站建设制作公司合肥seo优化
  • 石家庄造价信息网seo网络推广经理招聘
  • 网页网站关系网站制作定制
  • 企业网站seo点击软件网络推广和竞价怎么做
  • 代网站建设长春百度推广公司
  • 徐汇网站建设推广百度竞价排名官网
  • 重庆企业网站建设公司网站内部seo优化包括
  • 盘锦网站建设兼职培训计划方案模板
  • 重庆网站建设公司哪个最好seo网站查询
  • 昌平最好的网站建设百度下载并安装到桌面
  • 一站式服务建站南宁市优化网站公司
  • 房地产网站制作公司营销策划是做什么
  • 如何对网站做优化搜索引擎优化公司排行
  • 用哪个软件做网站好uc搜索引擎入口
  • 深圳燃气公司电话95158独立站seo推广
  • 有个网站做彩盒的seo优化价格
  • 做网站用java好还是c网站设计
  • 为什么我有的网站打不开优化的意思
  • 自学做网站可以嘛网络宣传推广方法