Skip to content

Instantly share code, notes, and snippets.

@wermarter
Created January 22, 2017 09:20
Show Gist options
  • Save wermarter/254446667446f8630671ceb2b26ab8a3 to your computer and use it in GitHub Desktop.
Save wermarter/254446667446f8630671ceb2b26ab8a3 to your computer and use it in GitHub Desktop.
Color filtering and Bitwise AND
import cv2, time, sys
from random import *
import numpy as np
cap = cv2.VideoCapture(0)
while 1:
_, frame = cap.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_clr = np.array([0,0,0])
upper_clr = np.array([176,100,100])
mask = cv2.inRange(frame, lower_clr, upper_clr)
cv2.imshow('', cv2.bitwise_and(frame, frame, mask=mask))
if cv2.waitKey(1) & 0xFF == 27:
break
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment