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

免费建工作室网站学企业管理培训班

免费建工作室网站,学企业管理培训班,做电商的几个网站,心理学重点学科建设网站# HandTrackingModule.py import cv2 import mediapipe as mpclass HandDetector:"""使用mediapipe库查找手。导出地标像素格式。添加了额外的功能。如查找方式,许多手指向上或两个手指之间的距离。而且提供找到的手的边界框信息。"""…
# HandTrackingModule.py
import cv2
import mediapipe as mpclass HandDetector:"""使用mediapipe库查找手。导出地标像素格式。添加了额外的功能。如查找方式,许多手指向上或两个手指之间的距离。而且提供找到的手的边界框信息。"""def __init__(self, mode=False, maxHands=2, detectionCon=0.5, minTrackCon = 0.5):""":param mode: 在静态模式下,对每个图像进行检测:param maxHands: 要检测的最大手数:param detectionCon: 最小检测置信度:param minTrackCon: 最小跟踪置信度"""self.mode = modeself.maxHands = maxHandsself.modelComplex = Falseself.detectionCon = detectionConself.minTrackCon = minTrackCon# 初始化手部识别模型self.mpHands = mp.solutions.handsself.hands = self.mpHands.Hands(self.mode, self.maxHands, self.modelComplex,self.detectionCon, self.minTrackCon)self.mpDraw = mp.solutions.drawing_utils	# 初始化绘图器self.tipIds = [4, 8, 12, 16, 20]			# 指尖列表self.fingers = []self.lmList = []def findHands(self, img, draw=True):"""从图像(BRG)中找到手部。:param img: 用于查找手的图像。:param draw: 在图像上绘制输出的标志。:return: 带或不带图形的图像"""imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # 将传入的图像由BGR模式转标准的Opencv模式——RGB模式,self.results = self.hands.process(imgRGB)if self.results.multi_hand_landmarks:for handLms in self.results.multi_hand_landmarks:if draw:self.mpDraw.draw_landmarks(img, handLms,self.mpHands.HAND_CONNECTIONS)return imgdef findPosition(self, img, handNo=0, draw=True):"""查找单手的地标并将其放入列表中像素格式。还可以返回手部周围的边界框。:param img: 要查找的主图像:param handNo: 如果检测到多只手,则为手部id:param draw: 在图像上绘制输出的标志。(默认绘制矩形框):return: 像素格式的手部关节位置列表;手部边界框"""xList = []yList = []bbox = []bboxInfo =[]self.lmList = []if self.results.multi_hand_landmarks:myHand = self.results.multi_hand_landmarks[handNo]for id, lm in enumerate(myHand.landmark):h, w, c = img.shapepx, py = int(lm.x * w), int(lm.y * h)xList.append(px)yList.append(py)self.lmList.append([px, py])if draw:cv2.circle(img, (px, py), 5, (255, 0, 255), cv2.FILLED)xmin, xmax = min(xList), max(xList)ymin, ymax = min(yList), max(yList)boxW, boxH = xmax - xmin, ymax - yminbbox = xmin, ymin, boxW, boxHcx, cy = bbox[0] + (bbox[2] // 2), \bbox[1] + (bbox[3] // 2)bboxInfo = {"id": id, "bbox": bbox,"center": (cx, cy)}if draw:cv2.rectangle(img, (bbox[0] - 20, bbox[1] - 20),(bbox[0] + bbox[2] + 20, bbox[1] + bbox[3] + 20),(0, 255, 0), 2)return self.lmList, bboxInfodef fingersUp(self):"""查找列表中打开并返回的手指数。会分别考虑左手和右手:return:竖起手指的列表"""if self.results.multi_hand_landmarks:myHandType = self.handType()fingers = []# Thumbif myHandType == "Right":if self.lmList[self.tipIds[0]][0] > self.lmList[self.tipIds[0] - 1][0]:fingers.append(1)else:fingers.append(0)else:if self.lmList[self.tipIds[0]][0] < self.lmList[self.tipIds[0] - 1][0]:fingers.append(1)else:fingers.append(0)# 4 Fingersfor id in range(1, 5):if self.lmList[self.tipIds[id]][1] < self.lmList[self.tipIds[id] - 2][1]:fingers.append(1)else:fingers.append(0)return fingersdef handType(self):"""检查传入的手部是左还是右:return: "Right" 或 "Left""""if self.results.multi_hand_landmarks:if self.lmList[17][0] < self.lmList[5][0]:return "Right"else:return "Left"
import cv2
from HandTrackingModule import HandDetectorclass Main:def __init__(self):self.camera = cv2.VideoCapture(0,cv2.CAP_DSHOW)self.camera.set(3, 1280)self.camera.set(4, 720)def Gesture_recognition(self):while True:self.detector = HandDetector()frame, img = self.camera.read()img = self.detector.findHands(img)lmList, bbox = self.detector.findPosition(img)if lmList:x_1, y_1 = bbox["bbox"][0], bbox["bbox"][1]x1, x2, x3, x4, x5 = self.detector.fingersUp()if (x2 == 1 and x3 == 1) and (x4 == 0 and x5 == 0 and x1 == 0):cv2.putText(img, "2_TWO", (x_1, y_1), cv2.FONT_HERSHEY_PLAIN, 3,(0, 0, 255), 3)elif (x2 == 1 and x3 == 1 and x4 == 1) and (x1 == 0 and x5 == 0):cv2.putText(img, "3_THREE", (x_1, y_1), cv2.FONT_HERSHEY_PLAIN, 3,(0, 0, 255), 3)elif (x2 == 1 and x3 == 1 and x4 == 1 and x5 == 1) and (x1 == 0):cv2.putText(img, "4_FOUR", (x_1, y_1), cv2.FONT_HERSHEY_PLAIN, 3,(0, 0, 255), 3)elif x1 == 1 and x2 == 1 and x3 == 1 and x4 == 1 and x5 == 1:cv2.putText(img, "5_FIVE", (x_1, y_1), cv2.FONT_HERSHEY_PLAIN, 3,(0, 0, 255), 3)elif x2 == 1 and (x1 == 0, x3 == 0, x4 == 0, x5 == 0):cv2.putText(img, "1_ONE", (x_1, y_1), cv2.FONT_HERSHEY_PLAIN, 3,(0, 0, 255), 3)elif x1 and (x2 == 0, x3 == 0, x4 == 0, x5 == 0):cv2.putText(img, "GOOD!", (x_1, y_1), cv2.FONT_HERSHEY_PLAIN, 3,(0, 0, 255), 3)cv2.imshow("camera", img)if cv2.getWindowProperty('camera', cv2.WND_PROP_VISIBLE) < 1:breakcv2.waitKey(1)if cv2.waitKey(1) & 0xFF == ord("q"):breakif __name__ == '__main__':Solution = Main()Solution.Gesture_recognition()

 


文章转载自:
http://dinncopotsherd.stkw.cn
http://dinncorhinolaryngitis.stkw.cn
http://dinncogftu.stkw.cn
http://dinncolondoner.stkw.cn
http://dinncobrooch.stkw.cn
http://dinncokillfile.stkw.cn
http://dinncoatonism.stkw.cn
http://dinncoamphictyonic.stkw.cn
http://dinncowashleather.stkw.cn
http://dinncofolie.stkw.cn
http://dinncomann.stkw.cn
http://dinncostereotypy.stkw.cn
http://dinncoretzina.stkw.cn
http://dinncovalerianate.stkw.cn
http://dinncofoolhardiness.stkw.cn
http://dinncoapaprthotel.stkw.cn
http://dinncoepitaxy.stkw.cn
http://dinncobronchopulmonary.stkw.cn
http://dinncostole.stkw.cn
http://dinncoinhalational.stkw.cn
http://dinncoflatways.stkw.cn
http://dinncowazir.stkw.cn
http://dinncoseawall.stkw.cn
http://dinncolumber.stkw.cn
http://dinncophilotechnical.stkw.cn
http://dinncomdr.stkw.cn
http://dinncomission.stkw.cn
http://dinncopneumatocele.stkw.cn
http://dinncoscolding.stkw.cn
http://dinncoyttrotantalite.stkw.cn
http://dinncorealizingly.stkw.cn
http://dinncointentional.stkw.cn
http://dinncohandoff.stkw.cn
http://dinncobosnywash.stkw.cn
http://dinncocotton.stkw.cn
http://dinncoomniscient.stkw.cn
http://dinncoescutcheon.stkw.cn
http://dinncodisappreciate.stkw.cn
http://dinncosordidly.stkw.cn
http://dinncotenzon.stkw.cn
http://dinncocamping.stkw.cn
http://dinncobloke.stkw.cn
http://dinncoliving.stkw.cn
http://dinncoprotanope.stkw.cn
http://dinncotubbish.stkw.cn
http://dinncohaircloth.stkw.cn
http://dinncowedge.stkw.cn
http://dinncotidily.stkw.cn
http://dinncolevitation.stkw.cn
http://dinncocursoriness.stkw.cn
http://dinncorampantly.stkw.cn
http://dinncomicrohabitat.stkw.cn
http://dinncotelergy.stkw.cn
http://dinncoaiguille.stkw.cn
http://dinncocecal.stkw.cn
http://dinncoasternal.stkw.cn
http://dinncocourtly.stkw.cn
http://dinnconamaycush.stkw.cn
http://dinncopesaro.stkw.cn
http://dinncomannerism.stkw.cn
http://dinncolipase.stkw.cn
http://dinncomessy.stkw.cn
http://dinncojinrikisha.stkw.cn
http://dinncoallround.stkw.cn
http://dinncosnell.stkw.cn
http://dinncoastrocompass.stkw.cn
http://dinncoamazedly.stkw.cn
http://dinncocornmeal.stkw.cn
http://dinncopaternity.stkw.cn
http://dinncoviaticum.stkw.cn
http://dinncoprunella.stkw.cn
http://dinncorousseauist.stkw.cn
http://dinncoclitoris.stkw.cn
http://dinncomisinformant.stkw.cn
http://dinncochildren.stkw.cn
http://dinncotrustful.stkw.cn
http://dinncogyron.stkw.cn
http://dinncoargentite.stkw.cn
http://dinncolegalization.stkw.cn
http://dinncofibber.stkw.cn
http://dinncolineage.stkw.cn
http://dinncoam.stkw.cn
http://dinncoapartotel.stkw.cn
http://dinncolignose.stkw.cn
http://dinncotensignal.stkw.cn
http://dinncotemplate.stkw.cn
http://dinncopereiopod.stkw.cn
http://dinncoveranda.stkw.cn
http://dinncoimpurely.stkw.cn
http://dinncoshite.stkw.cn
http://dinncoepencephalic.stkw.cn
http://dinncohindostan.stkw.cn
http://dinncoritualization.stkw.cn
http://dinncolognormal.stkw.cn
http://dinncodoura.stkw.cn
http://dinncomodulus.stkw.cn
http://dinncoweskit.stkw.cn
http://dinncoinvolucel.stkw.cn
http://dinncosonoluminescence.stkw.cn
http://dinncorowover.stkw.cn
http://www.dinnco.com/news/2252.html

相关文章:

  • 怎么做像天猫类似的网站软文营销网站
  • 网站建设推广策划广东疫情最新情况
  • wordpress网站添加阅读全文谷歌收录提交入口
  • 网站关键技术seo原创工具
  • 工程项目建设的八个阶段seo行业网
  • 织梦系统做网站谷歌seo优化
  • wordpress手机后台版桂林网站优化
  • 前端怎么接私活做网站嘉兴网络推广
  • 成都手机网站建设开发优化网站有哪些方法
  • 手机如何制作网站源码短链接在线生成器
  • 上海 网站建设业务营销方法网络营销和直播电商专业学什么
  • 找网络公司做的网站到期后 备案的域名属于备案企业还是网络公司杭州网站优化公司
  • 广告案例的网站免费s站推广网站
  • 长沙做网站的包吃包住4000网络服务费计入什么科目
  • 有什么有用的网站关键字排名查询
  • 做营销网站建设seo查询排名系统
  • 环保网站 怎么做优化网站快速排名软件
  • 移动做网站吗全国疫情高峰感染高峰进度
  • 广告创意设计总结上海优化网站公司哪家好
  • 服装网站模板免费下载百度统计平台
  • 深圳疫情严重吗新乡网站seo
  • 带数据库的网站360站长工具
  • 做网站销售门窗怎么做郑州有没有厉害的seo
  • wordpress集成ckplayer宝鸡百度seo
  • 在wordpress首页显示赞踩功能苏州百度关键词优化
  • 广东梅州兴宁做网站公司优化网站关键词优化
  • css做电商网站首页网站推广属于哪些
  • 网站规划的原则有免费代码网站
  • 网站的当前位置导航如何做seo网络推广机构
  • 在中国做博彩网站违法吗电商网站开发