The goals of this project are to
- 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.
The code for this section is in the 2nd and 3rd cells of the ipython notebookAdvanced Lane Detection.ipynb
. The first cell
finds the corners of 20 chessboard images given as examples using the OpenCV function findChessboardCorners
. This function finds the objpoints and image points. These are fed into the cv2.undistort
to get the distortion matrix used to undistort the image.
Here is the detected chessboard corners
This distortion matrix is used to undistort the lane images cell number 5 shows the sample undistorted image.
I then applied the perspective transform and defined a function called wrap
. This function takes in image, src(source) and dst(destination) matrices. I have manually coded these matrices in the cell #7 in the notebook. After applying perspective transform we have the following image
I then explored individual RGB channels to detect the best channel for detecting lane line
I then explored the HLS channels
I then applied gradient thresholding to orginal images. I used all the three different techiniques taught the course
-
absoulte x and y gradient using
cv2.Sobel
function the corresponding code is found in the cells 13 and 14 -
Magnitude thresholding here i used the kernal size as 25 and min thresh =25 and max thresh = 255
-
Direction thresholding. The corresponding function is in the cells 17 and 18 where i used the kernal size = 7 and min threshold is 0.0 and max thershold is 0.09
I then combined all the 3 techniques and found the best using different thresholding
I first used the HLS channels and used thresholds to detect lane lines. I found out the L channel is best for while lane; and thershold (220,255) are used in the custom function hls_binary
.
and then used the B channel in the Lab color space for detecting the yellow lines. Found in the cell 25.
I then used the above developed structure and then used it on all the test images given the output is shown below
I then used the given framework in the course to fit a polynomial to the lines detected using the above structure and also used the sliding window to detect the lane lines along throgh out the image
the corresponding histogram is shown below
I have also used an alternate method used to make continuas polyfit using the same code used in the course
I have then used the function curv_rad function to determine the radius of curvature and center of the car in the lane. Using all the framework generated we have the following image
I have then used the moviepy package to apply to the project video the code was successfully able to detect all the lane lines throughout the video. The link for the video is here
This project was pretty straight forward. The main challenge was to detect the yellow lines. After some online researching I found out that the Lab (B) channel is the best for this purpose. My code had some trouble applying to challenge video, more fine tuning is necessary for this purposes.