Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions Basics/ColorPicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

############################################
cap = cv2.VideoCapture(1)
path = 'test.png'
path = "test.png"
############################################


def empty(a):
pass

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down