1

我正在研究车道线检测。我目前的工作策略是:

  1. 定义一个感兴趣的区域,其中车道线可能是

  2. 扭曲图像以获得鸟瞰图

  3. 将图像转换为 YUV 颜色空间

  4. 归一化 Y 通道

  5. 拟合二阶多项式和滑动窗口方法

一切正常,但有阴影的地方算法不起作用。我尝试过自适应阈值,otssu 阈值,但没有成功。

没有阴影的源图像: 在此处输入图像描述

处理后的无阴影源图像:

在此处输入图像描述

带阴影的源图像:

在此处输入图像描述

处理后的带有阴影的源图像:

在此处输入图像描述

在第二张图片中,可以看出没有检测到阴影区域。实际上阴影会降低图像值,因此我尝试使用低于前一张新图像的新值对图像进行阈值处理,可以在此处找到:

在此处输入图像描述

这种技术不起作用,因为它带有很多噪音

目前我正在尝试背景减法和阴影去除技术,但它不起作用。从过去的 2 到 3 周,我对这个问题感到震惊。任何帮助将不胜感激......

import cv2
import matplotlib.pyplot as plt
import numpy as np 
from helper_functions import undistort, threshholding, unwarp,sliding_window_polyfit
from helper_functions import polyfit_using_prev_fit,calc_curv_rad_and_center_dist
from Lane_Lines_Finding import RoI
img = cv2.imread('./test_images/new_test.jpg')
new =undistort(img)
new = cv2.cvtColor(new, cv2.COLOR_RGB2BGR)
#new = threshholding(new)
h,w = new.shape[:2]
# define source and destination points for transform
imshape = img.shape
vertices = np.array([[
                      (257,670),
                      (590, 446),
                      (722, 440),
                      (1150,650)
                      ]], 
                      dtype=np.int32)  
p1 = (170,670)
p2 = (472, 475)
p3 = (745, 466)
p4 = (1050,650)

vertices = np.array([[p1,
                      p2,
                      p3,
                      p4
                      ]], 
                      dtype=np.int32)  
masked_edges = RoI(new, vertices)
#masked_edges = cv2.cvtColor(masked_edges, cv2.COLOR_RGB2BGR)


src = np.float32([(575,464),
                  (707,464), 
                  (258,682), 
                  (1049,682)])
dst = np.float32([(450,0),
                  (w-450,0),
                  (450,h),
                  (w-450,h)])
warp_img, M, Minv = unwarp(masked_edges, src, dst)
warp_img = increase_brightness_img(warp_img)
warp_img = contrast_img(warp_img)
YUV = cv2.cvtColor(warp_img, cv2.COLOR_RGB2YUV)
Y,U,V = cv2.split(YUV)
Y_equalized= cv2.equalizeHist(Y)
YUV = cv2.merge((Y,U,V))
thresh_min = 253
thresh_max = 255
binary = np.zeros_like(Y)
binary[(Y_equalized>= thresh_min) & (Y_equalized <= thresh_max)] = 1

kernel_opening= np.ones((3,3),np.uint8)
opening = cv2.morphologyEx(binary, cv2.MORPH_OPEN, kernel_opening)
kernel= np.ones((7,7),np.uint8)
dilation = cv2.dilate(opening,kernel,iterations = 3)
4

0 回答 0