diff --git a/src/main/python/__pycache__/detector.cpython-38.pyc b/src/main/python/__pycache__/detector.cpython-38.pyc index 802fe1f..66288f9 100644 Binary files a/src/main/python/__pycache__/detector.cpython-38.pyc and b/src/main/python/__pycache__/detector.cpython-38.pyc differ diff --git a/src/main/python/detector.py b/src/main/python/detector.py index 4115374..caedfd9 100644 --- a/src/main/python/detector.py +++ b/src/main/python/detector.py @@ -7,12 +7,8 @@ # define orange hsv values (opencv range is h:0-180, s:0-255, v:0-255) # NOTE: BELOW VALS REPRESENT RED ACTUALLY BC I ONLY HAD A RED SPONGE TO USE -LOWER_ORANGE_HSV = np.array([3, 80, 80]) -UPPER_ORANGE_HSV = np.array([6, 255, 255]) - -LOW_THRESHOLD = 110 -HIGH_THRESHOLD = 255 - +# LOWER_ORANGE_HSV = np.array([3, 80, 80]) +# UPPER_ORANGE_HSV = np.array([6, 255, 255]) # orange hsv values # LOWER_ORANGE_HSV = np.array([3, 80, 80]) @@ -28,11 +24,11 @@ class Detector: def __init__(self): pass - def detectOrange(self, grayscale_image, threshold): + def detectOrange(self, grayscale_image, low_threshold, high_threshold): """NOTE: to threshold with monochrome image (single-channel, grayscale) to create a binary mask, can specify a SINGLE scalar value for lower/upper bounds returns: binary image (single-channel, 8-bit)""" - return cv2.inRange(grayscale_image, LOW_THRESHOLD, HIGH_THRESHOLD) + return cv2.inRange(grayscale_image, low_threshold, high_threshold) #return np.where(grayscale_image > threshold, 255, 0).astype(np.uint8) def find_largest_orange_contour(self, orange_mask: np.ndarray) -> np.ndarray: diff --git a/src/main/python/test.py b/src/main/python/test.py index 320ee2f..1404813 100644 --- a/src/main/python/test.py +++ b/src/main/python/test.py @@ -7,6 +7,9 @@ cap = cv2.VideoCapture(0) counter = 0 +LOW_THRESHOLD = 110 +HIGH_THRESHOLD = 255 + while(True): ret, frame = cap.read() @@ -24,7 +27,7 @@ # convert tuple from (height, width, # of channels) to just (height, width) frame_single_channel = frame[:,:,0] - orange_mask = d.detectOrange(frame_single_channel, threshold=100) + orange_mask = d.detectOrange(frame_single_channel, LOW_THRESHOLD, HIGH_THRESHOLD) contour = d.find_largest_orange_contour(orange_mask) #cv2.drawContours(frame, contour, 0, [255, 0, 0], 2) if contour is not None and d.contour_is_note(contour):