【发布时间】:2016-07-04 18:30:21
【问题描述】:
我使用此脚本进行颜色检测:
#导入必要的包
import numpy as np
import argparse
import cv2
#构造参数解析并解析参数
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", help = "path to the image")
args = vars(ap.parse_args())
#加载图片
image = cv2.imread(args["image"])
#定义边界列表
boundaries = [
([100,50,220],[135,80,245]),
]
# 循环遍历边界
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(image, lower, upper)
output = cv2.bitwise_and(image, image, mask = mask)
print (output)
# show the images
cv2.imshow("images", np.hstack([image, output]))
cv2.waitKey(0)
我需要一个用于颜色检测的布尔变量。 我该怎么做?
问候 托马斯
【问题讨论】:
标签: python opencv color-detection