Giter Site home page Giter Site logo

carnd-lanelines-p1's Introduction

Finding Lane Lines on the Road By [email protected]


Finding Lane Lines on the Road

The goals / steps of this project are the following:

  • Make a pipeline that finds lane lines on the road
  • Reflect on your work in a written report

Reflection

1. Pipeline

My pipeline consisted of 5 steps. Most of them were learned in the lesson.

2. Color Select

I use RGB filtering by applying white and yellow mask on the image. Here are the results:

alt text

3. Grayscale

After color select, I apply grayscaling on the images as shown here:

alt text

4. Smoothing With Gaussian Blur

For good practice, grayscaling images should be smoothing for edge detect. I choose Gaussian Blur to smooth the images.

alt text

5. Edge Detect

For edge detect, Canny Alg is a good choice.

alt text

6. ROI Select

After all above steps, I have gotten edge images. Now, I want to remove the unimportant part. The sky, the hill, the tree and others are unimportant. Interest Region is defined by four vertices.

width = image.shape[1]
height = image.shape[0]
v_top_left = [int(width*0.45), int(height*0.6)]
v_top_right = [int(width*0.6), int(height*0.6)]
v_bottom_left = [int(width*0.1), height-2]
v_bottom_right = [int(width*0.95), height-2]

Here is the results after applying it on the Canny images:

alt text

7. Hough Transform

I use Hough Transform to detect lines in the images.

alt text

8. Extrapolate line

After Hough Transform, we get a collection of line segments. How to find left line and right line? I use tuple <slope, intercept> to indicate a line. If slope is negative, it should be a left line. If slope is positive, it should be a right line. Through the way, we can get left lines collection and right lines colletion. The weighted average based on intercept length is applied to the two collections to find a left line and a right line.

def average_slope_intercept(lines):
    left_lane_lines    = [] # (slope, intercept)
    left_lane_weights  = [] # (length,)
    right_lane_lines   = [] # (slope, intercept)
    right_lane_weights = [] # (length,)
    
    for line in lines:
        for x1, y1, x2, y2 in line:
            if x2==x1:
                continue # ignore a vertical line
            slope = (y2-y1)/(x2-x1)
            intercept = y1 - slope*x1
            length = np.sqrt((y2-y1)**2+(x2-x1)**2)
            if slope < 0: # y is reversed in image
                left_lane_lines.append((slope, intercept))
                left_lane_weights.append((length))
            else:
                right_lane_lines.append((slope, intercept))
                right_lane_weights.append((length))

    # Weight slopes and Y_intercepts by their line lenght
    right_lane = np.dot(right_lane_weights, right_lane_lines) / np.sum(right_lane_weights) if len(right_lane_weights) > 0 else None
    left_lane  = np.dot(left_lane_weights,  left_lane_lines) / np.sum(left_lane_weights)  if len(left_lane_weights) > 0 else None

    return right_lane, left_lane

See result example: alt text

9. Final Videos

You can find videos from the link:

Potential shortcomings with the pipeline

  • Identifying curves.
  • The line quality is tested when the car is driving at higher speeds.
  • I think there should be a more robust and dynamic method of identifying the road's horizon rather than just including 60% of the image height.
  • Polynomial fit for lane line fit

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.