Project Overview
The goal of the project was to write a computer vision pipeline using OpenCV to identify the lane boundaries from a dashcam video. The pipeline was written in Python using the OpenCV Computer Vision library.
The following steps were taken in order to achieve the goals of the project:
- Compute the camera calibration matrix and distortion coefficients given a set of chessboard images.
- Apply a distortion correction to raw images.
- Use color transforms gradient thresholds to create a thresholded binary image.
- Apply a perspective transform to rectify binary image.
- Detect lane pixels and fit to find the lane boundary.
- Determine the curvature of the lane and vehicle position with respect to center.
- Warp the detected lane boundaries back onto the original image
Camera Calibration
I start by preparing “object points”, which will be the (x, y, z) coordinates of the chessboard corners in the world. Here I am assuming the chessboard is fixed on the (x, y) plane at z=0, such that the object points are the same for each calibration image. I used these object points and corresponding image points that would exist to calculate the distortion. Luckily OpenCV provides methods such as cv2.calibrateCamera() to make this easier
Detecting Lane Lines and Curvature
Using a combination of color and gradient thresholds, I was able to generate a pretty decent looking binary image. The binary image is then masked remove excess noise and then warped using a perspective transform to achieve a birds-eye view of the lane lines. Finally I was able to use the histogram method to detect points along curved lines and used those points to fit a polynomial.
Here are some examples from the intermdiate steps:
Failures and Future Work
There are a lot of fluctuations in my pipeline. One thing to note is I tried implementing search based on previous poly fits but that caused the fluctuations to worsen. Additionally, I tried implementing smoothing as well but that showed no significant improvement. Future work involves implementing a solution to search around the already found lane lines as opposed to finding them for each frame. Furthermore, in order to make my pipeline more robust, I could implement better sanity checking that would make the overall output smoother.