Finding Lane Lines on the Road

Writeup


Finding Lane Lines on the Road

The goals / steps of this project are the following:

  • Make a pipeline that finds lane lines on the road
  • Reflect on your work in a written report

Reflection

1. Pipeline

Pipeline that I created worked as follows:

The pipeline accepted an image as its parameter and then greyscaled it.

greyscaledimage = cv2.cvtColor(original_img, cv2.COLOR_RGB2GRAY)

The purpose of greyscaling the image is to change a three channel image to single channel image.This helped us in computing purpose and for the steps that followed further: greyscaledimage The greyscaled image was then blurred using the gaussian glur.The purpose of bluring the image is to decrease the sharpness of the image and help in extracting required features of the image.Gaussian Blur took a parameter kernel.

blurredimage = cv2.GaussianBlur(original_img, (kernel_size, kernel_size), 0)

blurredimage

The Blurred image was then fed into the canny edge detection function.The purpose of this function is to bring out the edges of the objects in the image.The function is passed two parameters,low threshold and high threshold.The purpose of these threshold is to qualify what edges should make to the final output or not.The output of this function is an image that had all the edges demarcated:

edged_image = cv2.Canny(img, low_threshold, high_threshold)

cannyedgedimage

Next this image which has all its edge shown is then masked by region of interest.This resion of interest is only the lanes in front of the vehicle.The image is bounded by a trapezoid that marks only the lanes:

 vertices = np.array([[point1,point2,point3,point4]], dtype=np.int32)
 region_bound_image = region_of_interest(edged_image,vertices)

roiimage

This filtered out image from the region of interest function is passed to hough transform function.Hough Transform function helps in creating continuous line segement from the broken edges.This function accepts parameters that could help in tuning the accuracy of the functions output.The image that comes as ouput has line segments demarcating the lanes clearly. Hough Transform function calls another function called draw_line.The Drawline function takes the lines generated by hough transform and then extrapolate a line that is the average of all the line ie the best fitted line that could represent the lanes. np.polyfit function was used to get the best slope and intercept of the line that could represent the extrapolated version of the all the lines.The function ignored all the lines that had slope less that 0.3,to avoid distorted lane line in some scenarios.

    rho= 1
    threshod = 30
    theta = np.pi/180
    min_len=20
    max_len=30
    hough_output = hough_lines(region_bound_image,rho,theta,threshod,min_len,max_len)

houghtransformedimage

Final Image

finalimage

2. Potential Shortcomings of the current pipeline.

The potential shortcomings of the current pipeline are as follow:- * This Pipeline works only on images that has specific size but not on any range of size's * This Pipeline would not work on curved lane.It could handle only those lanes that are straight * This Pipeline would not work on images that have poor lighting conditions,distortions,variabilty in lane features.

3.Possible Imporvements on the current pipeline.

The possible improvements to the pipe * Detect curved line by extrapolating small line segments and then combining them to detect curved lane lines. * Work on different light conditions and colored lanes ie the code should work on lane lines that have range of colors possibly between yellow and white and mask out all the rest color distortions. * The region of interest chosen for the pipeline must change dynamically ie depending upon the image dimension or image scenario the region of interest should change.