【发布时间】:2019-09-17 09:24:06
【问题描述】:
我想检测黄色和白色车道。
如果我使用 RGB 空间,
def select_rgb_white_yellow(image):
# white color mask
lower = np.uint8([123, 116, 116])
upper = np.uint8([186, 172, 160])
white_mask = cv2.inRange(image, lower, upper)
# yellow color mask
lower = np.uint8([134, 121, 100])
upper = np.uint8([206, 155, 87])
yellow_mask = cv2.inRange(image, lower, upper)
# combine the mask
mask = cv2.bitwise_or(white_mask, yellow_mask)
masked = cv2.bitwise_and(image, image, mask = mask)
return masked
我只有白色车道。
所以稍微调整一下,使用 HLS 空间,使用这段代码。
def convert_hls(image):
return cv2.cvtColor(image, cv2.COLOR_RGB2HLS)
然后,再次提取黄白车道,
def select_white_yellow(image):
converted = convert_hls(image)
# white color mask
lower = np.uint8([0, 0, 0])
upper = np.uint8([0, 0, 255])
white_mask = cv2.inRange(converted, lower, upper)
# yellow color mask
lower = np.uint8([ 10, 0, 100])
upper = np.uint8([ 40, 255, 255])
yellow_mask = cv2.inRange(converted, lower, upper)
# combine the mask
mask = cv2.bitwise_or(white_mask, yellow_mask)
return cv2.bitwise_and(image, image, mask = mask)
然后它就无法检测到白色车道了。有没有同时检测白色和黄色车道的好方法?
这是我找到的所有 RGB 颜色代码
Yellow
c2974A (194, 149, 74)
a07444 (160, 116, 68)
b38e55 (179, 142, 85)
867964 (134, 121, 100)
ce9b57 (206, 155, 87)
ce9853 (206, 152, 83)
white
b4a59d (180, 165, 157)
b9a99a (185, 169, 154)
baaca0 (186, 172, 160)
867e79 (134, 126, 121)
7b7474 (123, 116, 116)
827d7c (130, 125, 124)
【问题讨论】:
-
我认为你应该分两个阶段来解决这个问题。先分出道路区域,然后得到线路。您可以在两者之间增强颜色以使其更容易。我使用this 脚本进行了快速测试,HSV 色彩空间似乎对白线效果很好,对于黄色,周围环境仍然是一个问题。因此:先把路分开;)
-
@J.D.
separate out the road是什么意思?切割天空部分?
标签: python opencv machine-learning computer-vision object-detection