This repo provides a pipeline of detecting lane lines from both image and video for autonomous vehicle(AV) using traditional computer vision techniques, i.e. Canny edge detection and hough transform approaches
- Read in image and convert it to grayscale with yellow color enhanced when necessary.
- Define a kernel size and apply Gaussain smoothing
cv2.GaussianBlur()
, which is essential to suppressing noise and spurious gradients by averaging. - Define low and high thresholds and run Canny edge detection
cv2.Canny()
- Select region of interest(ROI)
cv2.fillPoly()
- Define Hough transform parameters, apply Hough transform
cv2.HoughLinesP()
in ROI selected image to obtain lane line data. - Group the obtained lane line data into left and right lane. Calculate the average slope and intercept of left and right group respectively. Draw the lane line based on the average slope, average intercept and coordinate rage of each group.
- Generate the result by weighted summation of lane line image and the initial image
Note: The above pipeline needs tuning parameters for images from differen sources,i.e. image size, boundaries of ROI, parameters for Canny edge detection and Hough transform, etc
solidWhiteCurve.jpg
solidWhiteRight.jpg
solidYellowCurve.jpg
solidYellowCurve2.jpg
solidYellowLeft.jpg
whiteCarLaneSwitch.jpg
- Only linear lane can be found using this solution with acceptale accuracy. As for curve lane, the linear approximation method might lead to remarkable error(see test video 3
challenge.mp4
). - The algorithm is not so robust as it fails to group left or right lane correctly in some of frames in test video 2
solidYellowLeft.mp4
. - Bad weather conditions (snow, rain, etc.) and poor light contions will greatly affect the result.
- In this solution, the lane line detection result is based on the selection of ROI. It's acceptable to mask a ROI mannually for input videos comes from similar scenarios. However, complex and changeful scenarios might occur when AVs come into real road. This mannual selection approach undermines the accuracy and generalization of this solution.
- Adaptive approaches can be used to boost the generalization of current solution,especially for ROI selection.
- Add an outlier reduction approach like RANSAC on the hough lines
- Curve functions, such as B-spine, might be useful to detect non-linear lanes in curvy roads.