/Lane-line-detection-using-OpenCV

Detect lane lines in a video using basic Python and OpenCV

Primary LanguageJupyter NotebookMIT LicenseMIT

Finding Lane Lines on the Road

Udacity - Self-Driving Car NanoDegree

Combined Image

Overview

This project is an amalgamation of Python, OpenCV and my growing love for CV ;)

Pipeline used for lane line detection :

  • Input Image
  • Converting to Grayscale
  • Gaussian Blur
  • Canny edge detection
  • ROI selection
  • Hough Lines detection

Installations

  1. Install Anaconda on your local setup (Choose Python 3 version - Link)
  2. Create an environment (More on environments here) Open cmd and type - > conda create --name myenv This will create an environment with default python version, which is Python 3 for this project.
  3. Activate the environment, using > activate myenv
  4. Install Libraries : OpenCV : > conda install -c conda-forge opencv moviepy (used in this project to work with videos): > pip install moviepy

Each stage result

Input Image

Input Image

Grayscaled Image

Grayscaled Image

Gaussian Blurred Image

Gaussian Blurred Image

Canny Edge Detection

Canny Edge Detection

ROI Selection

CROI Selection

Hough Lines

Hough Lines

Final Output

Final Output

Extrapolatoin of line segments

  • All the line segments are divided into left_lane_lines and right_lane_Lines using slopes of the lines
  • A line is fitted to both sets resulting in one line for each side

Improved Hough Lines

Improved Hough Lines

Improved Final Output

Improved Final Output

HSV Color Space

When working with images and color selection HSV color space becomes quite handy (Learn more about HSV and HSL color space here). HSV Cylinder Using Hue Saturation Value color space and cv2.inRange() function we can select any color range from image. This technique is used for final challenge video.