赞
踩
总共分三个部分
第一步采用hls提取颜色空间,选择S通道
后面的阈值可以根据自己的需要进行调整,一般取值min=80,max=255
def hls_select(img, channel='S', thresh=(90, 255)): # 1) Convert to HLS color space # 2) Apply a threshold to the S channel # 3) Return a binary image of threshold result hls = cv2.cvtColor(img, cv2.COLOR_RGB2HLS) if channel == 'S': X = hls[:, :, 2] elif channel == 'H': X = hls[:, :, 0] elif channel == 'L': X = hls[:, :, 1] else: print('illegal channel !!!') return binary_output = np.zeros_like(X) binary_output[(X > thresh[0]) & (X <= thresh[1])] = 1 return binary_output
然后是提取白色车道线部分,阈值化提取
参数可自行调整,一般min=200+ ,max=255
def r_select(img, thresh=(222, 255)):
R = img[:,:,0]
binary = np.zeros
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。