/Lane-Detection

Lane Detection for autonomous driving done in python/C++ OpenCV

Primary LanguagePython

Lane Detection in OpenCV

gif

Overview

Lane detection for a car driving on the highway using OpenCV in python. Two videos are used and the detected lane is drawn over each frame. The output videos correspond to the test_videos.

Method

For each frame, the first step is to grayscale the image

original

grayscaled

then a gaussian filter is applied

gaussiansmoothed

Canny edge detection is used on the smoothed image

cannyedge

An area of interest is used to filter out irrelevant parts of the image

masked

Hough lines are found and separated into positive and negative slopes

houghlinesall

Slope averages and x intercept averages are found for positive and negative lines, and the average lane line for positive and negative are found

lanelinesaverage

The lane is filled in and the result is written to the output video

finalout

Dependencies

  • numpy
  • matplotlib
  • OpenCV 3.x

Running

Running LaneDetect_OneFrame only uses one frame and displays images at each step of the process. Running LaneDetect will go through the frames in test_video and write an output.avi. The test video used is currently specified on lines 19 and 20.

TODO

Use Homography to get birds eye view of image, fit a curve to the lane in this view and transform back to draw lane lines more accurately.

References