Code Monkey home page Code Monkey logo

lane_detection-turn_prediction's Introduction

Lane_Detection

This project outlines a simple algorithm to perform lane detection and turn prediction for a self driving car. This will attempt to replicate techniques used in lane departure and warning systems. The video used for this project can be found here.

Procedure

Lane Detection

  • Each frame of the video is read sequentially
  • Each image is undistorted by using the camera matrix and the distortion coefficients provided here.
  • The lane lines in the video are of two colors, yellow and white, therefore extraction of both is important.
  • The image is converted to the HSV color space and a mask for the yellow line is generated by using the threshold values for yellow.
  • Next, the original image is converted to grayscale and aggressive thresholding is performed. Finally the mask with the yellow line is added to this image.
  • Canny edge detection is used to extract edges from this image.

edges

  • A trapezoidal region of interest is then defined and the following operations are performed only withing this region of interest.
  • We then use probabilistic hough transform (ro=6, theta=3, threshold=35, minimum_line_length=40 and maximum_line_gap=150) to detect lines in the edge map.
  • Since this operation fits multiple lines for each edge we will now compute the optimal line for each left and right lane marker.
  • This is done by computing the average intercept and slope for all lines pertaining to the left and right lane marker respectively. The lines pertaining to these slopes and intercepts are considered to be the detected lane markers.
  • The center line of the lane is then computed by taking the average of the x and y co-ordinates of lane markers.
  • The OpenCV polyfill function is used to fill the lane on a blank image and a weighted sum of the lane mesh with the original image is used to overlay the lane mesh on the road.

lane_markers

Turn Prediction

  • Turn prediction is achieved by using the center line of the lane. Since the the center of the road keeps shifting in the video, a static point of reference cannot be used to infer whether the car is veering to the left or the right.
  • Hence, the x co-ordinate of the bottom most point of the center line is used as the dynamic point of reference.
  • The deviation of the top most point of the center line is used to determine whether the car is to turn left, right, or remain heading straight. Appropriate thresholds are set for the same.

c_img

The final result is show below.

lane_detect

Steps to run the program

Clone this repository and run the follow line in the terminal to run the lane detection and turn prediction algorithm for the given video.

cd ...<path_to_repository>/code/
python3 lane_detect.py

lane_detection-turn_prediction's People

Contributors

lldev-rootll 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.