我目前正在研究一个包括颜色检测的项目。我在 python 上使用 opencv 来做到这一点,我可以检测到我想要的颜色,即蓝色,但我无法让软件知道这种颜色已被检测到。这是我的代码。
` hsv_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 边界 = [([94, 90, 45], [145, 255, 255])]
# loop over the boundaries
for (lower, upper) in boundaries:
# create NumPy arrays from the boundaries
lower = np.array(lower, dtype="uint8")
upper = np.array(upper, dtype="uint8")
# find the colors within the specified boundaries and apply
# the mask
mask = cv2.inRange(hsv_frame, lower, upper)
output = cv2.bitwise_and(frame, frame, mask=mask)
imageOut = np.hstack([frame, output])`
Run Code Online (Sandbox Code Playgroud)
它正确地隔离了蓝色,就像 我的代码的输出一样。
我的问题是,从那里我不知道如何让我的软件知道蓝色已被检测到并隔离。