Detected highway lane lines on a video stream. Used OpencV image analysis techniques to identify lines, including Hough Transforms and Canny edge detection.
When we drive, we use our eyes to decide where to go. The lines on the road that show us where the lanes are, act as our constant reference for where to steer the vehicle.
This project proposes an algorithm to automatically detect lane lines using OpenCV and Python, including Hough Transforms and Canny edge detection. Detected highway lane lines on a video stream.
Anaconda is used for managing my dependencies.
(Note: the hyperlinks only works if you are on the homepage of this GitHub reop, and if you are viewing it in “github.io” you can be redirected by clicking the View the Project on GitHub on the top)
P1.ipynb is the main code for demos.
test_images contains the test images.
test_videos contains the test videos.
Besides, there are some testing videos and images.
(1) If you using Anaconda or miniconda, activate your environment which includes the dependencies by:
source activate your-conda-environment
(2) Load jupyter notebook and then select the P1.ipynb by:
jupyter notebook
1) apply the gaussian blur
2) convert bgr to hsv and segment while and yellow (because it is easier in HSV space than RGB)
3) Canny edge detection
4) apply the designed mask to the image to obtian the region of interest
5) apply hough transform to get lines
6) augmented the lanes on the original image
7) a buffer is used to smooth the line positions between frames.
Canny edge detection is implemented by using opencv function as follows:
edges = cv2.Canny(gray, low_threshold, high_threshold)
One example is shown as below:
A line in Image Space is a point in Hough Space.
A point in Image Space is a line in Hough Space. Then we divide the Hough Space into grid, and define the intersecting lines as all lines passing through a given grid cell.
Since vertical lines have infinite slope in y = mx+b
representation, so we define a line in polar coordinates as
shown in the following fiugre.
Each point in image space corresponds to a sine curve in Hough Space. Therefore, if we take a line of points, it translates into a whole bunch of sine curves in Hough Space, and the intersection of those sine curves gives the parameters of the line.