In this project several computer vision techniques are applied to detect lanes on the read and draw lines fitting them.
Step 1: Set up Anaconda with OpenCV
Step 2: Open the P1.ipynb in a Jupyter Notebook (Python 3.5)
Step 3: Run the notebook
- Apply gray scale to the initial image
- Use Gaussian blur technique to distinct the white lanes and input to canny edge method
- Apply Canny edge method to find the edges in the image
- Apply a mask to spot only the lanes
- Use Hough transformation to obtain the most suitable lines passing over the edges
- Obtain fitting lines
In order to draw a single line on the left and right lanes, I modified the ** draw_lines()** function by separating into positive and negative slope . Besides filter into two branches of positive/negative slope, I apply a range of acceptable values for slope according to the plot of all possible hough lines. This range was within [0.4, 0.95] for positive slopes and [-0.95,-0.4] for negative slopes. Afterwards, I evaluate the average slope for left and right lines (positive/negative slopes) in order to find a single line for both cases. Finally, using simple linear equation y = mx +b , I obtained the parameter b as well as extrapolate the right and left lines.