-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_color.py
48 lines (33 loc) · 1 KB
/
get_color.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import argparse
import cv2
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", help="path to image")
args = vars(ap.parse_args())
image = cv2.imread(args["image"])
boundaries = [
# lower B, G, R < upper B, G, R
#([178,160,10], [200,185,110]),
#([240,220,10], [255,255,150]),
#([209,195,140], [229,215,162]),
#([189,164,87], [209,184,107]),
#([126,109,35], [146,129,55])
([127,117,80], [183,177,141]),
]
dullBlueGrey = [
#8db1b7 <-> 50757f
([127,117,80], [183,177,141])
]
darkBlueShades = [
#56a3be <-> 84bac8
([190,163,86], [200,186,133])
]
for (lower, upper) in boundaries:
lower = np.array(lower, dtype = "uint8")
upper = np.array(upper, dtype = "uint8")
mask = cv2.inRange(image, lower, upper)
output = cv2.bitwise_and(image, image, mask = mask)
if(output.any() > 0):
print("Prius Detected.")
cv2.imshow("images", np.hstack([image, output]))
cv2.waitKey(0)