Python

  • t0_772002
    了解作者
  • 9.5MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-16 03:12
    上传日期
Python
Python-master.zip
  • Python-master
  • geckodriver.log
    12.1KB
  • drivers
  • chromedriver.exe
    6.4MB
  • IEDriverServer.exe
    2.9MB
  • geckodriver.exe
    16.2MB
  • MicrosoftWebDriver.exe
    97.2KB
  • specs
  • test.log
    451B
  • UnitTestS.py
    2.2KB
  • AutomationLogs.py
    1.1KB
  • assertions.py
    1.1KB
  • unittestexample.py
    1.1KB
  • HTMLReport.py
    985B
  • geckodriver.log
    19.4KB
  • debug.log
    2.2KB
  • python_cmd.PNG
    13.6KB
  • unittestexample1.py
    1.7KB
  • DataDriven.py
    1.1KB
  • mouse_keyboard.py
    924B
  • JSPopUps.py
    292B
  • Redbus.py
    2.6KB
  • game.py
    3.3KB
  • Driver.py
    509B
  • Driver1.py
    940B
  • teardown.py
    2.2KB
  • Browsers.py
    1.4KB
  • rest_api.py
    175B
  • Selenium.py
    1.7KB
  • package-lock.json
    2.7KB
  • userinput.py
    433B
  • data
  • Google.png
    33.1KB
  • data.json
    314B
内容介绍
# Imports import numpy as np import cv2 import math import pyautogui # Open Camera capture = cv2.VideoCapture(0) while capture.isOpened(): # Capture frames from the camera ret, frame = capture.read() # Get hand data from the rectangle sub window cv2.rectangle(frame,(100,100),(300,300),(0,255,0),0) crop_image = frame[100:300, 100:300] # Apply Gaussian blur blur = cv2.GaussianBlur(crop_image, (3,3), 0) # Change color-space from BGR -> HSV hsv = cv2.cvtColor(blur, cv2.COLOR_BGR2HSV) # Create a binary image with where white will be skin colors and rest is black mask2 = cv2.inRange(hsv, np.array([2,0,0]), np.array([20,255,255])) # Kernel for morphological transformation kernel = np.ones((5,5)) # Apply morphological transformations to filter out the background noise dilation = cv2.dilate(mask2, kernel, iterations = 1) erosion = cv2.erode(dilation, kernel, iterations = 1) # Apply Gaussian Blur and Threshold filtered = cv2.GaussianBlur(erosion, (3,3), 0) ret,thresh = cv2.threshold(filtered, 127, 255, 0) # Find contours image, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE ) try: # Find contour with maximum area contour = max(contours, key = lambda x: cv2.contourArea(x)) # Create bounding rectangle around the contour x,y,w,h = cv2.boundingRect(contour) cv2.rectangle(crop_image,(x,y),(x+w,y+h),(0,0,255),0) # Find convex hull hull = cv2.convexHull(contour) # Draw contour drawing = np.zeros(crop_image.shape,np.uint8) cv2.drawContours(drawing,[contour],-1,(0,255,0),0) cv2.drawContours(drawing,[hull],-1,(0,0,255),0) # Fi convexity defects hull = cv2.convexHull(contour, returnPoints=False) defects = cv2.convexityDefects(contour,hull) # Use cosine rule to find angle of the far point from the start and end point i.e. the convex points (the finger # tips) for all defects count_defects = 0 for i in range(defects.shape[0]): s,e,f,d = defects[i,0] start = tuple(contour[s][0]) end = tuple(contour[e][0]) far = tuple(contour[f][0]) a = math.sqrt((end[0] - start[0])**2 + (end[1] - start[1])**2) b = math.sqrt((far[0] - start[0])**2 + (far[1] - start[1])**2) c = math.sqrt((end[0] - far[0])**2 + (end[1] - far[1])**2) angle = (math.acos((b**2 + c**2 - a**2)/(2*b*c))*180)/3.14 # if angle >= 90 draw a circle at the far point if angle <= 90: count_defects += 1 cv2.circle(crop_image,far,1,[0,0,255],-1) cv2.line(crop_image,start,end,[0,255,0],4) # Press SPACE if condition is match if count_defects >=3: pyautogui.press('space') cv2.putText(frame,"JUMP", (150,100), cv2.FONT_HERSHEY_SIMPLEX, 2, 2, 2) except: pass # Show required images cv2.imshow("Gesture", frame) # Close the camera if 'q' is pressed if cv2.waitKey(1) == ord('q'): break capture.release() cv2.destroyAllWindows()
评论
    相关推荐
    • Python
      Python
    • python
      Python 这是用于大多数基本和简单python代码的示例模板的存储库。
    • Python
      Python项目 Python是一些简单的Python项目,它是一种解释性的高级通用编程语言,我愿意学习它为将来的许多项目做出贡献! 入门 您必须安装Python 3.9.2才能尝试这些项目。 这些项目来自各种书籍,您可以根据需要进行...
    • Python
      Python Dit是Mijn储存库van Python
    • python
      Python 基本的python编程
    • Python
      Python python和pyspark
    • python
      关于python的学习资料。。。。。。。
    • python学习
      python学习 安装Python 我们转到Python页面进行初始下载:( )在为Mac OSX选择了最新版本(3.9.2)之后,我将其下载到了我的计算机上。 然后,我们搜索了“ Python入门”,并确认VS Code是适用于Python的可行代码...
    • Fluent Python
      This book was written for practicing Python programmers who want to become proficient in Python 3. If you know Python 2 but are willing to migrate to Python 3.4 or later, you should be fine. At the ...
    • Python
      Python 该存储库包含与Python编程研究相关的文档