Giter Site home page Giter Site logo

carnd-advanced-lane-lines's Introduction

Advanced Lane Finding

Udacity - Self-Driving Car NanoDegree

The 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.

The images for camera calibration are stored in the folder called camera_cal. The images in test_images are for testing your pipeline on single frames. If you want to extract more test images from the videos, you can simply use an image writing method like cv2.imwrite(), i.e., you can read the video in frame by frame as usual, and for frames you want to save for later you can write to an image file.

To help the reviewer examine your work, please save examples of the output from each stage of your pipeline in the folder called ouput_images, and include a description in your writeup for the project of what each image shows. The video called project_video.mp4 is the video your pipeline should work well on.

The challenge_video.mp4 video is an extra (and optional) challenge for you if you want to test your pipeline under somewhat trickier conditions. The harder_challenge.mp4 video is another optional challenge and is brutal!

If you're feeling ambitious (again, totally optional though), don't stop there! We encourage you to go out and take video of your own, calibrate your camera and show us how you would implement this project from scratch!

Camera Calibration

Camera calibration is implemented in CameraCalibrator. CameraCalibrator.calibrate uses opencv.calibrateCamera to compute the camera matrix and distance coefficients that can be used to undistort images.

Image undistortion is implemented in ImageUndistorter. ImageUndistorter.undistort uses opencv.undistort to undistort an image. There is a utility methods here to save images in a folder etc.

Distorted image correction samples

Distorted Undistorted
calibration1.jpg calibration1_undistort.jpg
straight_lines1.jpg straight_lines1_undistort.jpg

Thresholded binary image

Image binarizing is implemented in ImageBinarizer. This process combines binary images produced by 2 separate techniques.

s_channel_binary

Perform and RGB to HLS color space transform and select only highlight in the s-channel of the transformed image.

straight_lines1_undistort_s_binary.jpg

gradient_threshold_binary

This method uses the sobel operator to detect edges of lanes which is an improvement over canny edge detection since that detects all edges.

straight_lines1_undistort_sxbinary.jpg

combined

Combination of the 2 techniques gives us a clearer detection of lane lines in an image as show in the sample below.

straight_lines1_undistort_binary.jpg

Perspective transform

Perspective transform is implemented in PerspectiveTransformer and uses opencv.getPerspectiveTransform to compute the transform matrix. opencv.warpPerspective is used to warp the perspective of an undistored image. The dst and src points detrmination was based on a bit of trial and error to come up with a warped imaged with a good bit of information.

Undistorted Warped
straight_lines1_undistort.jpg straight_lines1_undistort_warped.jpg
straight_lines1_undistort_binary.jpg straight_lines1_undistort_binary_warped.jpg

Lane extraction

Lane extraction is based on the implementation provided in lecture slides. LaneExtractor and uses Line to store interim state. LaneExtractor has 2 methods extract_lane_from_scratch and extract_lanes_based_on_previous that are the actual lane extraction method based on determining historgam to determine the start of lines and then using a window method to move to the top of the frame to detect the entire line.

Without With
straight_lines1_undistort_binary_warped.jpg straight_lines1_undistort_binary_warped_lanes.jpg

LaneExtractor has implementation of get_curvature to return curavture given the x distance of the lane left and right lines.

Pipeline

A pipeline to process a single image is coded up in Pipeline. The process_single_image method is the implementation to process a single image, detect a lane and super impose a filled polygon on the returned image.

input output
straight_lines1.jpg straight_lines1_lane_found.jpg

Each image in the video to be processed will be processed by the process_single_image method and transformed to the output image.

The final video outputs of the project is as follows -

input video output video annotated video
input output annotated output

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.