Skip to content

BilalSi20/Lane-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Lane Detection Project

Overview

This project is inspired by the Teknofest 2025 Efficiency Challenge competition and implements one of the core ADAS (Advanced Driver Assistance Systems) functions: lane keeping. The system is designed to enable autonomous driving by processing live video from a camera mounted on a vehicle, detecting lane lines in real time, and providing steering guidance. Using OpenCV and other Python libraries, the project demonstrates how a vehicle can follow lanes autonomously, making it suitable for research, competitions, and educational purposes related to self-driving technologies.


Features

  • Lane Detection: Detects lane lines using advanced image processing techniques.
  • Curve Prediction: Measures curve radius and predicts steering direction (left, right, or straight).
  • Perspective Adjustment: Adjustable perspective points for different video inputs.
  • Live Camera Support: Supports video input from a webcam.
  • Resolution Compatibility: All processing is optimized for 1280x720 resolution.
  • Visual Indicators: Marks perspective points and detected lanes on the video.
  • Error Handling: Handles empty lane detection gracefully without crashing.

Installation

Prerequisites

Ensure the following software and libraries are installed:

  • Python 3.6 or higher
  • OpenCV 4 or higher
  • Numpy 1.20 or higher
  • Matplotlib 3.3 or higher

Setup

  1. Clone the repository:
    git clone https://github.com/your-repo/lane-detection.git
  2. Install the required Python libraries:
    pip install opencv-python numpy matplotlib

How It Works

Main Workflow

  1. Video Input: The system reads video input from a file or webcam.
  2. Image Processing: Applies HLS filtering, grayscale conversion, thresholding, and edge detection.
  3. Perspective Warp: Adjusts the perspective to a bird's-eye view for better lane detection.
  4. Lane Detection: Uses sliding window and histogram techniques to detect lane lines.
  5. Curve Measurement: Calculates the radius of curvature and predicts the curve direction.
  6. Lane Visualization: Draws detected lanes and perspective points on the video.
  7. Error Handling: Displays the raw frame if lane detection fails.

Key Functions

  • readVideo(): Reads video input from a file or webcam.
  • processImage(): Processes the image to isolate lane lines.
  • perspectiveWarp(): Warps the perspective for better lane detection.
  • plotHistogram(): Plots the histogram of white pixels.
  • slide_window_search(): Detects lane lines using sliding window technique.
  • measure_lane_curvature(): Measures the curve radius and direction.
  • draw_lane_lines(): Visualizes detected lanes on the video.
  • addText(): Adds curvature and deviation information to the video.

Usage

  1. Place your video file (V1.mp4) in the project directory.
  2. Run the script:
    python Lane_Detection.py
  3. Press Enter to stop the video playback.

Customization

  • Perspective Points: Modify the src array in the perspectiveWarp() function to adjust perspective points.
  • Lane Colors: Change the lower_colour and upper_colour arrays in processImage() to detect different lane colors.

Troubleshooting

  • Empty Lane Detection: If no lanes are detected, the system will display the raw frame with a warning message.
  • Resolution Handling: The code automatically resizes any input to 1280x720 for optimal processing.

Acknowledgments

  • Developed by Bilal Sinav
  • Inspired by advanced driver assistance systems (ADAS) functions as followed in the Teknofest 2025 Efficiency Challenge competition for autonomous vehicles.
  • Also inspired by Can Ozcivelek's lane detection project.

Contact

For questions or feedback, please contact Bilal Sinav.

About

A computer vision project for real-time lane detection using OpenCV and Python, designed for front-facing vehicle cameras in autonomous driving applications

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages