Skip to content

Instantly share code, notes, and snippets.

@InputBlackBoxOutput
Created March 28, 2022 03:52
Show Gist options
  • Save InputBlackBoxOutput/15bfe99c9c68719f283b8bbb6ef5c7e0 to your computer and use it in GitHub Desktop.
Save InputBlackBoxOutput/15bfe99c9c68719f283b8bbb6ef5c7e0 to your computer and use it in GitHub Desktop.
Green color segmentation using HSV value thresholding
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