When we drive, we use our eyes to decide where to go. The lines on the road that show us where the lanes are act as our constant reference for where to steer the vehicle. Naturally, one of the first things we would like to do in developing a self-driving car is to automatically detect lane lines using an algorithm.
The goal of this project is to piece together a pipeline to detect the line segments in the image, then average/extrapolate them and draw them onto the image for display.
This is project #1 of my Self Driving Car Projects
Python 3 is used along with the numpy, matplotlib, cv2, moviepy, and glob.
The python source files are:
process_imagefunction that combines pipeline functions that implements the methods described above.
run.py- processes video or test images. See “Running” section below.
The tools used for lane line detection are color selection, region of interest selection, grayscaling, Gaussian smoothing, Canny Edge Detection and Hough Tranform line detection. These methods form the pipeline to process each image from video to detect lane lines.
Canny image output
Region of Interest masked
Line segments highlighted
Result lane lines image
python run.py produces images in output_images from test_images folder
python run.py video_in.mp4 video-out.mp4 produces project and challenge video outputs
Currently, the pipeline is only shown to work for this particular camera and setup. It may not work on camera with different resolution; where the vertical center is higher or lower; and many other scenarios such as night time, bad weather conditions, etc.
Constants used for outliers detection in lane_lines(), min line length, and max line gap in hough_lines(), and elsewhere will probably need better methods for determination instead of trail and error.
Even though the algorithm detected the 2 video lanes fairly well, it produce quite a few bad lane detection frames for the challenge video. I tried to detect false lines better by saving the previous 3 frame’s slope and intersect and use those instead for outliers detection. But turns out either it wasn’t useful or more likely, mistake was made somewhere. Since we already know the colors of the lanes, color filtering can be used to enhance the detection as well to make it work better.
A more elaborate approach to lane line detection is done in project 4.
Next up is project 2 - Traffic Sign Classifier.