【发布时间】:2020-05-26 21:05:30
【问题描述】:
我需要检测两种颜色,一种接一种。
所以这是我的程序工作流程的一个例子:
检测并找到具有特定颜色的对象,在该对象与相机足够近(指定多少)后,
程序应尝试开始寻找另一种颜色。
这是我迄今为止尝试过的
# All python's imports
vs = VideoStream(src=0).start()
# Defining the two colors bound
blueLower = np.array([110, 50, 50])
blueUpper = np.array([130, 255, 255])
greenLower = np.array([29, 86, 6])
greenUpper = np.array([64, 255, 255])
# Defining a function to start the loop so i can later rerun it with different color bounds
def loop(lower, upper):
while True:
....
....
# If the object is close enough, change the loopj arguments to search for a new color
if radius > 250:
loop(greenLower, greenUpper)
会发生什么,当半径大于 250 时,它只是重新运行原来的
【问题讨论】:
-
这是准确的代码吗?如果您每次都明确发送
greenLower和greenUpper,它不会每次都搜索不同的颜色。您需要在每个函数调用中交替使用green和blue。 -
“你需要在每个函数调用中用绿色和蓝色交替”,我怎样才能做到这一点。
标签: python opencv object-detection