Street Lanes Finder - Detecting Street Lanes for Self-Driving Cars 🚗

Lanes Detection with Computer Vision

Greg Surma
5 min readJul 25, 2019


In today’s article, we are going to use basic Computer Vision techniques to approach the street lanes detection problem which is crucial for self-driving cars. By the end of this article, you will be able to perform real-time lane detection with Python and OpenCV.

Real-Time Lane Detection


You can find the full codebase for this project on GitHub and I encourage you to check it and follow along.

Let’s start with defining our problem.

Given an image of the road, we would like to detect street lanes on it.

In order to do it, let’s provide an image path and load it with OpenCV, then let’s invoke find_street_lanes pipeline with it.

test_image = cv2.imread(INPUT_FOLDER + TEST_IMAGE)
street_lanes = find_street_lanes(test_image)

And this is how our find_street_lanes pipeline looks like


The first step of our pipeline is an image conversion from color to grayscale. We do it because in our case color values don’t hold any valuable information so to make further processing simpler and faster, we convert from three channels to one.

grayscale = (r + g + b) / 3