Lane-Detection
Lane-Detection copied to clipboard
A python software to detection lane lines on the road. Built for self-driving cars.
Lane-Detection
This is a Python command line project made with Python, OpenCV, and Numpy.
Getting started
- Install python 3
- Clone the repo
- Install dependencies
-
pip3 install -r requirements.txt
- Run project
-
python3 main.py
How to use
- The program will automatically detect all lanes/edges in the lower half of the video.
- You can use your own video by replace the
input.mp4
file. - Press
q
to exit the program.
How it works?
First, a frame is captured from the MP4 video. Then we define a region_of_interest
with vertices as (100, height), (width/2, height/2), (width, height)
, which is essentially a triangle starting at the bottom corners, and peaking at the mid point of the image. All further calculations happen in this region.
Next, we plan to use the Canny Algorithm to detect the edges in the frame, but we first convert the image to grayscale for best results. After this, we crop the image to remove everything but our region of interest triangle, and call the OpenCV's in-built HoughLinesP
function on it. This coupled with the draw function will create the lines(shown with green) and then superimpose them on our original frame, which is finally returned. This process is repeated for every frame in the video.
Output
https://user-images.githubusercontent.com/55011564/126891188-5b2cd095-0518-4702-8eb3-561bada60047.mp4