Code Monkey home page Code Monkey logo

advanced-lane-detection-2's Introduction

Lane Finding Documentation

By: Kyle Stewart-Frantz


Scope:

  1. Camera Calibration
  2. Distortion Correction
  3. Perspective Transform
  4. Color and Gradient Threshold
  5. Detect Lane Lines
  6. Determine Lane Curvature
  7. Impose Lane Boundaries on Original Image
  8. Output Visual Display of Lane Boundaries and Numerical Estimation of Lane Curvature and Vehicle Position

1. Camera Calibration

The first step in the project is camera calibrations which is done with the provided images in the camera_cal folder. Using findChessboardCorners the corners are extracted and fed into the calibrateCamera function. This function then provides us with our image matrix and the distortion coefficents. With this information we can move onto step 2.

2. Distortion Correction

Using the image matrix, the distortion coefficents and the undistort function the images can be properly undistored. To check that the images have been properly undistored a before and after has been applied to a checker board pattern.

alt text

3. Perspective Transform

Now for this part I decided to transform before applying my thresholds on the image. (Contrary to how the helper functions are written). This was done with the getPerspectiveTransform and warpPerspective funtions.

Transform Points

Source Destination
250, 700 250, 700
1200, 700 1200, 700
550, 450 300, 50
750, 450 1000, 50
Visualization of Transform

alt text

4. Color and Gradient Threshold

With the transform in place several pixel extractions were appliled and all combined into a final bitmask that is used in the next part. The labor for these functions is done with the respective color and gradient threshold funcitons. The layer and treshold type is provided in the table below.

Bit Extraction Table

Color Layer Applied Too Threshold Type
Red Layer (RGB) Threshold
Value Layer (HSV) Threshold
Yellow Extraction (HSV) In Range
White Extraction (HSV) In Range
White Extraction (HSL) In Range
White Extraction (RGB) In Range
Visualization of Bit Mask

alt text

5. Detect Lane Lines

Lane lines were found by sliding a histogram window from the bottom of the bit mask to the upper 3/4 range. At each slice a point was indexed for were the highest density of pixels were found. See below for visualization.

alt text

6. Determine Lane Curvature

Using the points gathered from the lane detction a 2nd order polynomial was fit to the data. With the new polynomial fit, new points were generated to simulate the entire lenth of the line. This can be seen below.

alt text

7. Impose Lane Boundaries on Original Image

Lanes were imposed by taking the polynomial fit points and feeding them int opencv's poly fill to fill the polygon. From there the new polygon was then undistored, trucated, and imposed onto the rode as seen below.

alt text

8. Output Visual Display of Lane Boundaries and Numerical Estimation of Lane Curvature and Vehicle Position

Lastly, distance from the center and the lane curvature were calculated from the bottom most pixels and updated every 10 frames and displayed in the dashboard.

A finalized frame is seen below:

alt text

Final Thoughts

This was an absoultly fantastic experience. At first the lanes were all over the place and very jittery. I applied techniques to help such as make sure that the polygon that comes after was of similar shape, I also ruled out polygons that failed to meet area requirements. When there errors arrose the last correct polygon was written instead.

Future improvents to avoid the algoritm from failing is a much cleaner bit mask extraction. When tested on the most difficult video the main problem was addtional noise creating points that ruined the polynomial fit. With more time a better bit mask extraction can be applied to enhace this algorithm.

advanced-lane-detection-2's People

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.