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)
我需要顏色的布爾變量檢測與否。 我該怎麼做?
問候 托馬斯