Advanced Lane Finding Project
The goals / steps of this project are the following:
- Compute the camera calibration matrix and distortion coefficients given a set of chessboard images.
- Apply a distortion correction to raw images.
- Use color transforms, gradients, etc., to create a thresholded binary image.
- Apply a perspective transform to rectify binary image ("birds-eye view").
- 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.
- Output visual display of the lane boundaries and numerical estimation of lane curvature and vehicle position.
Rubric Points
Here I will consider the rubric points individually and describe how I addressed each point in my implementation.
The code for this step is contained in the fourth code cell of the IPython notebook located in "P2.ipynb".
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. Thus, objp
is just a replicated array of coordinates, and objpoints
will be appended with a copy of it every time I successfully detect all chessboard corners in a test image. imgpoints
will be appended with the (x, y) pixel position of each of the corners in the image plane with each successful chessboard detection.
I then used the output objpoints
and imgpoints
to compute the camera calibration and distortion coefficients using the cv2.calibrateCamera()
function. I applied this distortion correction to the test image using the cv2.undistort()
function and obtained this result:
By using camera calibration and distortion coefficients I undistort the image. Undistorted output:
I have used HLS color transform. Sobel gradient in x and y direction conbined to get thresholded binary image. The code for this step is contained in the eighth code cell of the IPython notebook located in "P2.ipynb". Following is binary image:
The code for this step is contained in the tenth code cell of the IPython notebook located in "P2.ipynb".
Its takes source and destination point, which uses cv2.getPerspectiveTransform(src, dst)
and return transformation matrix.
When source and destination got interchanged we get inverse transformation matrix, which will be used in
reverting the transformed image. I have use straight line image to do so. This matrix is used to transformation of
other images.
The code for this step is contained in the fifteenth code cell of the IPython notebook located in "P2.ipynb".
The code for this step is contained in the seventeenth code cell of the IPython notebook located in "P2.ipynb".
The code for this step is contained in the eighteenth code cell of the IPython notebook located in "P2.ipynb".
The code for this step is contained in the twenty-eighth code cell of the IPython notebook located in "P2.ipynb".
Here's a link to my output video result
- Other gradients can be use to detection eg. Laplacian.
- Code can be optimize to be faster by avoiding calaulation repetation.
- Accuracy can be improved by using information in sequence of images instead dealing with single image.