Skip to content

Advanced Lane Finding Project for Udacity Self Driving Car Nanodegree.

License

Notifications You must be signed in to change notification settings

josancamon19/advanced_lane_finding

Repository files navigation

Advanced Lane Finding

Lanes Image

In this project, your goal is to write a software pipeline to identify the lane boundaries in a video, but the main output or product we want you to create is a detailed writeup of the project. Check out the writeup template for this project and use it as a starting point for creating your own writeup.


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.


Camera Calibration

1. Briefly state how you computed the camera matrix and distortion coefficients. Provide an example of a distortion corrected calibration image.

I started by preparing "object points", which was the (x, y, z) coordinates of the chessboard corners in the world. Here I assummed that 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:

alt text

Pipeline (single images)

1. Provide an example of a distortion-corrected image.

To demonstrate this step, I will describe how I apply the distortion correction to one of the test images like this one:

undistorted

2. Describe how you used color transforms, gradients or other methods to create a thresholded binary image. Provide an example of a binary image result.

I used a combination of color(getting the HLS colors and thresholding the S channel) and gradient thresholds like sobel_x to generate a binary image (thresholding steps at the first cell in 2. color and gradient section. Here's an example of my output for this step.

alt text

3. Describe how (and identify where in your code) you performed a perspective transform and provide an example of a transformed image.

The code for my perspective transform includes a function called perspective_transform(), which appears in the first cell in the section 3. Perspective Transform in the Jupyter Notebook. The perspective_transform() function takes as inputs an image (img, inverse(bool)), as well as source (src) and destination (dst) points. I chose the hardcode the source and destination points in the following manner:

src_coordinates = np.float32([[270, 700], [600,460], [728,460], [1080, 700]])
dst_coordinates = np.float32([[250, 720, ], [290, 0], [1060, 0], [1100, 720]])

I verified that my perspective transform was working as expected by drawing the src and dst points onto a test image and its warped counterpart to verify that the lines appear parallel in the warped image.

alt text

4. Describe how (and identify where in your code) you identified lane-line pixels and fit their positions with a polynomial?

Then I did some other stuff and fit my lane lines with a 2nd order polynomial kinda like this:

alt text

5. Describe how (and identify where in your code) you calculated the radius of curvature of the lane and the position of the vehicle with respect to center.

I did this in lines first cell in the section 5. Draw lanes plane in the Jupyter Notebook.

  1. I built some fake lines
  2. Fitted a second order polynomial to pixel positions in each fake lane line
  3. Defined conversions in x and y from pixels space to meters
  4. Fitted new polynomials to x,y in world space
  5. Calculated the new radius of curvature

6. Provide an example image of your result plotted back down onto the road such that the lane area is identified clearly.

I implemented this step in the first three cells in the section 6. set metrics of the Jupyter Notebook.

  1. Calculated radius of curvature
  2. Calculated car offset
  3. Display lane curvature using cv2.PutText
  4. Display car offset

metrics

---

Pipeline (video)

1. Link to the final video output. The pipeline performed well on the entire project video

Here's a link to my video result


Discussion

1. Briefly discuss any problems / issues I faced in your implementation of this project. What could you do to make your pipeline more robust?

Here I'll talk about the approach I took, what techniques I used, what worked and why, where the pipeline might fail and how I might improve it if I were going to pursue this project further.

The most important thing I want to discuss, is the thresholds, that's basically the reason behind the error in the harder video challenge, the thresholds work great basically, but I only used 2 thresholds, the first threshold the S channel of the HLS color space and then I applied a sobelx, so, it worked great doing the task required, but the better approach in order to build a better pipeline would be using more thresholds to gain as much information as possible and remove all interference and noise that is giving us problems in harder scenarios, thresholds like the thresholding the pixels magnitud, thresholding the direction of the pixels,the other sobel, and others .

Releases

No releases published

Packages

No packages published