diff --git a/Basics/ColorPicker.py b/Basics/ColorPicker.py index 276a299..fd66276 100644 --- a/Basics/ColorPicker.py +++ b/Basics/ColorPicker.py @@ -3,9 +3,10 @@ ############################################ cap = cv2.VideoCapture(1) -path = 'test.png' +path = "test.png" ############################################ + def empty(a): pass @@ -20,11 +21,19 @@ def stackImages(scale, imgArray): for x in range(0, rows): for y in range(0, cols): if imgArray[x][y].shape[:2] == imgArray[0][0].shape[:2]: - imgArray[x][y] = cv2.resize(imgArray[x][y], (0, 0), None, scale, scale) + imgArray[x][y] = cv2.resize( + imgArray[x][y], (0, 0), None, scale, scale + ) else: - imgArray[x][y] = cv2.resize(imgArray[x][y], (imgArray[0][0].shape[1], imgArray[0][0].shape[0]), - None, scale, scale) - if len(imgArray[x][y].shape) == 2: imgArray[x][y] = cv2.cvtColor(imgArray[x][y], cv2.COLOR_GRAY2BGR) + imgArray[x][y] = cv2.resize( + imgArray[x][y], + (imgArray[0][0].shape[1], imgArray[0][0].shape[0]), + None, + scale, + scale, + ) + if len(imgArray[x][y].shape) == 2: + imgArray[x][y] = cv2.cvtColor(imgArray[x][y], cv2.COLOR_GRAY2BGR) imageBlank = np.zeros((height, width, 3), np.uint8) hor = [imageBlank] * rows hor_con = [imageBlank] * rows @@ -36,8 +45,15 @@ def stackImages(scale, imgArray): if imgArray[x].shape[:2] == imgArray[0].shape[:2]: imgArray[x] = cv2.resize(imgArray[x], (0, 0), None, scale, scale) else: - imgArray[x] = cv2.resize(imgArray[x], (imgArray[0].shape[1], imgArray[0].shape[0]), None, scale, scale) - if len(imgArray[x].shape) == 2: imgArray[x] = cv2.cvtColor(imgArray[x], cv2.COLOR_GRAY2BGR) + imgArray[x] = cv2.resize( + imgArray[x], + (imgArray[0].shape[1], imgArray[0].shape[0]), + None, + scale, + scale, + ) + if len(imgArray[x].shape) == 2: + imgArray[x] = cv2.cvtColor(imgArray[x], cv2.COLOR_GRAY2BGR) hor = np.hstack(imgArray) ver = hor return ver @@ -62,7 +78,7 @@ def stackImages(scale, imgArray): s_max = cv2.getTrackbarPos("Sat Max", "TrackBars") v_min = cv2.getTrackbarPos("Val Min", "TrackBars") v_max = cv2.getTrackbarPos("Val Max", "TrackBars") - print(f'{h_min},{h_max},{s_min},{s_max},{v_min},{v_max}') + print(f"{h_min},{h_max},{s_min},{s_max},{v_min},{v_max}") lower = np.array([h_min, s_min, v_min]) upper = np.array([h_max, s_max, v_max]) mask = cv2.inRange(imgHSV, lower, upper)