Guest User

Untitled

a guest
Jun 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4. cap = cv2.cv2.VideoCapture(0)
  5. kernel = np.ones((5,5), np.uint8)
  6.  
  7. while True:
  8. ret, frame = cap.read()
  9. rangomax = np.array([50,255,50])
  10. rangomin = np.array([0, 51, 0])
  11. mascara = cv2.cv2.inRange(frame, rangomin, rangomax)
  12. opening = cv2.cv2.morphologyEx(mascara, cv2.cv2.MORPH_OPEN, kernel)
  13. x,y,w,h = cv2.cv2.boundingRect(opening)
  14. cv2.cv2.rectangle(frame, (x,y), (x+w, y+h), (0,255,0), 3)
  15. cv2.cv2.circle(frame,(x+w/2, y+h/2), 5,(0,0,255), -1)
  16. cv2.cv2.imshow('video', frame)
  17. k = cv2.cv2.waitKey(1) & 0xFF
  18. if k == 27:
  19. break
  20. cap.release()
Add Comment
Please, Sign In to add comment