Created
January 22, 2017 09:20
-
-
Save wermarter/254446667446f8630671ceb2b26ab8a3 to your computer and use it in GitHub Desktop.
Color filtering and Bitwise AND
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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