This was a fun little project from the Udacity Self-Driving car class to detect car lanes.
The steps of the detect and draw lane lines pipeline on a sinlge image are:
- Convert the image to greyscale.
- Smooth the image via gaussian blur.
- Apply a canny edge detection algorithm.
- Mask the image so that we only detect on what we expect to be the field of vision for lane detection.
- Detect lines with Hough transformation and extrapolate and extend lane lines to be drawn. (This is where the interesting stuff happens, see below).
- Apply the drawn lane line image to the original image.
How the draw_lines() function is implemented:
- Divide into Left and Right Lanes the points detected in a line based on the slope.
- Extrapolate the coefficients for the line function using cv2.polyfit.
- Apply the coefficients in a fit function with cv2.poly1d.
- draw Right and Left lane lines based on output of the fit function.