Git Product home page Git Product logo

carnd-advanced-lane-lines's Introduction

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 file "advanced_lane_finder.ipynb" contains the complete source code of all the functionality defined in this document.

Camera Calibration

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

The code for this step is contained in the second code cell of the IPython notebook located in "advanced_lane_finder.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:

Distorted Image Undistorted Image
alt text alt text

Pipeline (single images)

Distortion corrected image

This is the first step in the pipeline to ensure that the given image is corrected for distortion so that the rest of the steps in the pipeline can work on a undistorted image. Steps followed are same as outlined in the section Camera Calibration"

Apply Perspective Transform

I defined the function "warp_image" to apply perpective transform on the lane portion of the image and warp the image. I referred to one of the references from the article https://medium.com/@vamsiramakrishnan/robust-lane-finding-using-python-open-cv-63eb66fa2616 to understand how to play around with the source pixel values.

Below are the pixes values I have chosed as source points for perspective transform: [200,660],[1200,660],[800,480],[540,480].

For Destination points, I have chosen the four corners of the image based on the image size.

Applying the warping step earlier in the pipeline helped me to focus only on the lane area of the image when I proceeded further with color and gradient threshold steps.

Test Image Warped Image
alt text alt text

Apply Color and Gradient Threshold

I applied various color and gradient thresholds and tried out different threshold values. Images below shows the impact to the image when various color and gradient thresholds are applied:

Warped Lane Image Gradient X Image Gradient Y Image Magnitude Image
alt text alt text alt text alt text
Direction S Channel Image H Channel Image Combined Threshold and Gradient
alt text alt text alt text alt text

I found that S channel was promising to detect lanes in most of the cases whereas direction images were noisy in most of the cases. After trying out different combinations, I skipped magnitude & direction and used the following code to derive the combination of color and gradient thresholds:

| combined[((gradx == 1) & (grady == 1)) | ((saturation_binary == 1) & (hue_binary == 1))] = 1 |

Apply sliding window search, fit a polynomial and highlight the lanes

I applied sliding window search(Refer the method sliding_window_search in cell#9) to identify the lanes. Generated a histogram of the binary thresholded image and used the following values for the sliding window search:

  • number of windows = 9
  • Min no.of pixels to recenter window = 50
  • Width of the window = 100

Once the left and right line pixels are identified, I applied second order polynomial function using np.polyfit function.

I also implemented the method "get_radius_of_curvature" to compute the radius of curvature of the left and right lanes in meter. The final image with the lanes highlighted is shown below:

Highlight Left and Right Lanes
alt text

Highlight Lanes in the original image and update details on radius of curvature and distance from lane centre

I implemented the method "highlight_lane"(Cell#10) to apply the image where the lane area is highlighted on the original image. The method "get_lane_center_info"(Cell #11) computer the position of the center of the car based on the pixel position of the left and right lanes. It compares this value against the horizontal center position of the image and checks how far the vehicle is from the center of the road in meter.

Pipeline

The method "pipeline" (Cell# 16) orchestrates all the above steps in order to produce the following result:

Unwarped Image with lanes highlighted
alt text

Pipeline (video)

The above pipeline was applied to the project_video.mp4 file and it worked pretty well to highlight the lanes).

Here's a link to my video result


Discussion

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

This pipeline works well in well light conditions and light shadows. It should be improved further to handle situations like dark shadows, poor visibility etc. Need to check on different color and gradient thresholds to handle such scenarios.

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.

carnd-advanced-lane-lines's People

Contributors

baumanab avatar brok-bucholtz avatar dinesh-i avatar harveenchadha avatar mreichelt avatar mvirgo avatar ryan-keenan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.