This repository contains a Python script for detecting and displaying lanes in a video using OpenCV.
Clone the repository.
Jump to the repository by using following command
cd Road-Lane-Detection-System
Maintain a single video in the repository with the name 'test.mp4' ,which is the default. If you opt to use an alternative video for testing, kindly remove the initial default video and rename your video to test.mp4
Before building the Docker image, install the basic framework for a GUI environment, specifically 'X11' (assuming users are using Ubuntu).
apt-get install x11-xserver-utils
To display a GUI-based application in Docker, Allow X server connection:
xhost +local:*
You will get message "non-network local connections being added to access control list".
To ensure a seamless Docker experience, it's essential to check the status of the Docker service on your system.To verify whether the Docker service is currently active or inactive, you can use the following steps:
systemctl status docker
if it's inactive, you'll need to take corrective action.
sudo systemctl start docker
Now, let's build the Docker image named 'lane_detection_app' using the docker build command:
sudo docker build -t lane_detection_app .
Write the following command to run a Docker container named 'lane_detection'
sudo docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ --name lane_detection lane_detection_app
:tada: Yeah,You will be able to see the video playing on the display.
After the completion of testing,make sure to disallow the X server connection:
xhost -local:*
You will get message "non-network local connections being removed from access control list".
The main code initializes the video capture object using the provided video file path. It creates a named window "Lane Detector" and adds two trackbars for adjusting the Canny edge detection thresholds. The script then proceeds to process each frame of the video:
canny
function.roi
function.cv.HoughLinesP
).displayLines
function.cv.addWeighted
.Feel free to modify the threshold values and the region of interest (roi_vertices
) to better suit your specific use case. Happy lane detection!