In this project, using Canny Edge Detector and OpenCV library the lane lines are identified from a camera image.
pip install opencv-python
pip install numpy
In this technique, edges are identified by sharp changes in the intensities of adjacent pixels. When we interpret an image as Numpy array,we get array of pixels where each pixel intensity is denoted by some numeric value ranging from 0 to 255.
- Gradient: It is a measure of change in brightness over adjacent pixels. Strong gradient implies sudden or sharp change, which gives us edges.
The following steps are followed while applying this technique.
- Convert an image from RGB to grayscale
- Reduce noise in image by applying Gaussian blur
This step can be skipped as the canny method provided by OpenCV applies Gaussian blur with 5 X 5 kernal before performing edge detection
- Apply Canny method
Now the next step is to consider only region of interest and get only the lane edges and ignore the remaining part of image.
From above cropped image we will draw Hough Lines using OpenCV function HoughLinesP to get lane lines.We can see in the left image that number of lines are detected for one lane line. This can be further optimized by taking average of slope and intercepts of both the lane lines and get the optimized results as shown in right image
This algorithm can further be applied to video as well, which will detect lane lines as we proceed.