We have already identified road markings in our image from a series of points in the gradient image using the Hough transform detection algorithm. We then took these lines and placed them in a blank image, which we then merged with our color image. We then displayed the lines on the input image. Now, we will further optimize it.
It is important to first recognize that the lines currently displayed correspond to the section that exceeded the voting threshold. They were voted as the lines that best described the data. Instead of having multiple lines, as seen on the left line in our image, we will now average out their slopes and y-intercepts into a single line that traces both of the lanes.
We will do this by adding two new functions to the code make_coordinates and average_slope_intercept:
- Import the required libraries:
In[1]: import cv2
In[2]: import numpy as np
In[3]: import matplotlib.pyplot...