0
我使用这个脚本用于颜色检测:OpenCV的蟒蛇颜色检测与布尔输出
#导入必要的包
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)
我需要颜色的布尔变量检测与否。 我该怎么做?
问候 托马斯