Created
March 28, 2022 03:52
-
-
Save InputBlackBoxOutput/15bfe99c9c68719f283b8bbb6ef5c7e0 to your computer and use it in GitHub Desktop.
Green color segmentation using HSV value thresholding
This file contains hidden or 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 | |
import numpy as np | |
import time | |
greenHSVLowerLimit = (24, 76, 0) | |
greenHSVUpperLimit = (84, 255, 255) | |
VideoStream = cv2.VideoCapture(0) | |
time.sleep(2.0) | |
while True: | |
ret, frame = VideoStream.read() | |
if ret == False: | |
break | |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) | |
frame = cv2.inRange(frame, greenHSVLowerLimit, greenHSVUpperLimit) | |
cv2.imshow("Frame", frame) | |
key = cv2.waitKey(1) & 0xFF | |
if key == ord("q"): | |
break | |
VideoStream.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment