Coder Social home page Coder Social logo

dhruv-pattel / road-lane-detection-system Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elle-bee/road-lane-detection-system

0.0 0.0 0.0 19.39 MB

Home Page: https://t.me/+__4-ipvNiw0yNTY1

License: MIT License

Python 80.82% Dockerfile 19.18%

road-lane-detection-system's Introduction

Road Lane Detection

This repository contains a Python script for detecting and displaying lanes in a video using OpenCV.

Lane Detection Example

Requirements

  • Docker Desktop

Usage

  1. Clone the repository.
  2. Jump to the repository by using following command
cd Road-Lane-Detection-System
  1. 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
  2. Prerequisites:

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".

  1. Verify Docker Status:

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:

  • Check Docker Service Status:
systemctl status docker

if it's inactive, you'll need to take corrective action.

  • To activate the Docker service, use the following command:
sudo systemctl start docker
  1. Build:

Now, let's build the Docker image named 'lane_detection_app' using the docker build command:

sudo docker build -t lane_detection_app .
  1. Run:

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

๐ŸŽ‰ Yeah,You will be able to see the video playing on the display.

  1. Closing Notes:

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".

Main Code

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:

  1. It reads a frame from the video.
  2. Applies Canny edge detection to the frame using the canny function.
  3. Masks the region of interest in the frame using the roi function.
  4. Detects lines in the masked frame using the Hough Line Transform (cv.HoughLinesP).
  5. Draws the detected lines on a new image using the displayLines function.
  6. Combines the original color frame and the lines image using cv.addWeighted.
  7. Displays the resulting frame in the "Lane Detector" window.
  8. The script continues processing frames until the user presses the 'q' key, at which point it terminates the video capture and closes the window.

Feel free to modify the threshold values and the region of interest (roi_vertices) to better suit your specific use case. Happy lane detection!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.