Lane Detection with Computer Vision
Lane detection is one of the important component of Autonomous Driving Vehicle Systems (ADAS). With the aim to detect the lane on the road, I have developed a pipeline using Python and OpenCV.
Pipeline consists of following steps —
- Grayscale conversion
- Gaussian Smoothing
- Canny Edge Detection
- ROI Selection
- Hough Transform
- Line Extrapolation
Grayscale Conversion
Convert RGB image to Grayscale which will help in color masking
Gaussian Smoothing
Gaussian smoothing is performed to reduce the noise in image.
Canny Edge Detection
Canny Edge Detection is performed to find the edges in the image. Two important parameters to consider in canny edge detection are — Lower threshold and High threshold. The algorithm will first detect strong edge (strong gradient) pixels above the high threshold, and reject pixels below the low threshold. Next, pixels with values between the low threshold and high threshold will be included as long as they are connected to strong edges
ROI Selection
ROI (Region of interest) selection is performed to remove the unwanted edges.
Hough Transform
Hough Transform is used to detect the lines from the edge detected image. Few of the important parameters to consider are
rho — distance resolution of grid in Hough space
theta — Angular resolution of grid in Hough space
threshold — minimum number of votes or intersections to consider that point as part of line
min_line_length — minimum length of line in pixels to consider it in output
max_line_gap — maximum gap between segments to be considered as single line
It is important to tweak this parameters to get the better results.
Line Extrapolation
Hough Transform provides multiple line segments but to draw a continuous left lane and right lane, I have used the line extrapolation method where I have taken average of slope of line segments for left and right lane respectively.
Code of this implementation is available at — https://github.com/ameykarmarkar/Computer-Vision-Lane-Detection