🛣 Lane Detection using Python
Cars, Machine Learning, Software Engineering
4945 views
Code I wrote in Python utilizing NumPy, OpenCV, etc., for Udacity's Self-Driving Car course. The flow goes like this:
Each video frame is processed as an image:
- Convert image to grayscale
- Apply a Gaussian blur to the grayscaled image
- Generate an image which only contains edges from the grayscaled image (Canny edge detection algorithm)
- Mask edges image to a region limited to where the camera would be positioned (a triangle in the middle)
- Determine coordinates of lines from the masked image (Hough transform algorithm)
- Extrapolate lines:
- Calculate min ys and max ys from lines
- Separate lines by slope, into left lines and right lines
- Calculate mean slope and intercept of left and right lines
- Calculate extrapolated line for each left and right lines
- Draw semi-transparent lines onto original image
Repeat for each video frame
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-01.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-02.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-03.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-04.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-05.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-06.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-07.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-08.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-09.png)
![](https://ejstembler-com.s3.amazonaws.com/img/posts/2016-12-05-lane-detection-using-python/P1-10.png)