This is my result of the first project in the Udacity's Self-Driving Car Nano-degree program.
The goal of the project is to build a pipeline to detect lanes on the road in a given video stream.
- The detected lane lines must be overlayed on the input video stream
- The lane detection should work for all the variant of road condition(straight,curved,shaded..etc) in the given video streams.
The resulting pipeline consists of 6 steps as described below.
We first convert our image into gray scale to make rest of the processing easier as we dont have to deal with all colors on the image. we're only interested in the white & yello images. cv2.cvtColor function is used for this.
The next step is to smoothen the image by bluring it using Gaussian blur (cv2.GaussianBlur)
From the blured image, we apply Canny's edge detection to extract the edges in the image using cv2.Canny function
The lane lines of our interest appear only in a specific region of the image. we mask rest of the image and keep only this area of interest.
In the interested region of the image, we apply Hough line transformation to detected lines using cv2.HoughLinesP function.
From the detected hough lines, we extract only those lines that match with the angle/slope of lane lines and ignore the rest of the detected lines.
Since there would be several partial lines detected from the above step, we extrapolate them to define the left & right lane lines. I use linear regression to extrapolate the lines.
Once we have the extrapolate lane lines, we then merge this on the original image.
The following are some of the shortcoming of this basic pipeline
- This pipeline works only in an ideal scenario of straight roads with good lane markings
- Curved regions are not handled since only a straight line extrapolation is done
- If the lane markings are spaced too widely, the pipeline will fail
- If the lane color is not in contract with the road/surroundings, the pipeline will fail to identify them
- this pipeline only handles RGB colorspace.
some of the possible improvement that immediately stike to my mind
- improve the line detection by performing a color threshold. (lane lines are presumed to be only in white or yellow)
- processing the image only in RGB color space might be able to detect lanes marking in all conditions(ex: shadowed region...etc). Therefore, using HSL/HSV to process the image could lead to better detection.
- Detecting curved lines is required as compared to detecting only straight lines
As seen above, the implemented pipeline is pretty basic and fails with most of the real life scenarios. Going forward in the course, I'll learn better ways to improve this pipeline.
You can find this basic pipeline implementation at my github repo here