Advanced Lane Detection with Computer Vision

Amey Karmarkar
2 min readOct 24, 2020

--

Lane detection is one of the important component of Autonomous Driving Vehicle Systems (ADAS). In the previous post, I developed the lane detection system with simple pipeline but one of the major limitation of algorithm was not able to detect the curved lane. This pipeline will take care of the curved lane and shadow on the road.

Pipeline consists of following steps —

  1. Camera Calibration
  2. Distortion Correction
  3. Threshold Binary Image
  4. Perspective Transform
  5. Finding lane line

Camera Calibration and Distortion Correction

Camera looks at 3D objects in the real world and transforms them into 2D image. Transformation of this 3D to 2D is not perfect every time, this is called as distortion. Distortion can change size, shape and appearance of the object. So calibrating camera and getting undistorted images is important. OpenCV provides functions to calibrate the camera and calculating distortion matrix.

OpenCV provides following functions :

  1. findchessboardcorners() — Finds chess board corners in the provided image
  2. calibrateCamera() — Returns distortion matrix
  3. undistort() — Returns undistorted image
Distortion Corrected Image

Threshold Binary Image

To mask the image and find pixels that are likely to be part of line in an image, I have performed Gradient thresholding using Sobel operator and Color thresholding. As one of the challenge is the lighting conditions, so color thresholding is performed in HSL(Hue, Saturation, Lightness) color space.

Threshold Image

Perspective Transform

In finding the lane line, finding the curvature of lane is very important. Perspective transform is used to transform an image in such a way that we are effectively viewing objects from different angle or direction. Here, original image is transformed to bird’s eye view which will help to find the curvature of lane and fit the polynomial.

OpenCV provides following functions to achieve the transform-

getPerspectiveTransform ()— returns the warpmatrix

warpPerspective() — returns the warped image

Perspective Transform Image

Finding Lane Line

After finding the warped image, to detect the line I have used the following steps —

  1. Finding Peaks in Histogram — Prominent peaks in the histogram will provide the tentative position of the left lane and right lane

2. Sliding Window approach — Finding the indices for potential left lane and right lane using sliding window approach

3. Fit polynomial — Based on the indices fitting a 2 degree polynomial to get the curve that fits the line.

Lane Detection Output

--

--

No responses yet