Guest User

Untitled

a guest
Dec 15th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #This program displays everything except the bounded color
  2.  
  3. import numpy as np
  4. import cv2
  5.  
  6. cap = cv2.VideoCapture(0)
  7.  
  8. while True:
  9. # Capture frame-by-frame
  10. ret, image = cap.read()
  11.  
  12. # define the list of boundaries
  13. boundaries = [
  14. ([86, 31, 4], [220, 88, 50])
  15. ]
  16.  
  17. # loop over the boundaries
  18. for (lower, upper) in boundaries:
  19. # create NumPy arrays from the boundaries
  20. lower = np.array(lower, dtype="uint8")
  21. upper = np.array(upper, dtype="uint8")
  22.  
  23. # find the colors within the specified boundaries and apply
  24. # the mask
  25. mask = cv2.inRange(image, lower, upper)
  26.  
  27. #output = cv2.bitwise_and(image, image, mask=mask)
  28. output = cv2.bitwise_and(image, image, mask=cv2.bitwise_not(mask))
  29. #outputTwo = cv2.bitwise_and(outputOne)
  30. #output = image | outputOne
  31. imageOut = np.hstack([image, output])
  32.  
  33. # Display the resulting frame
  34. cv2.imshow('RGB',imageOut)
  35. if cv2.waitKey(1) & 0xFF == ord('q'):
  36. break
  37.  
  38. # When everything done, release the capture
  39. cap.release()
  40. cv2.destroyAllWindows()
Add Comment
Please, Sign In to add comment