Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 

Repository files navigation

Lane Detection using Classical Computer Vision

This project implements a complete lane detection pipeline using OpenCV and traditional computer vision techniques.
It demonstrates the end-to-end process of detecting road lane markings from an image using noise filtering, edge detection, Hough Transform, and RANSAC line fitting β€” without using deep learning models.


🧠 Overview

  • Loaded a road image and converted it to grayscale.
  • Added and analyzed Gaussian and Salt & Pepper noise for robustness testing.
  • Applied multiple denoising filters (Gaussian, Median, Bilateral) and evaluated their performance using PSNR.
  • Detected edges automatically using a custom Auto-Canny function based on image statistics.
  • Used Hough Line Transform and RANSAC algorithms to extract dominant lane lines.
  • Compared both methods quantitatively using coverage metrics and visual overlays.

βš™οΈ Techniques Used

Stage Technique Purpose
Preprocessing Grayscale Conversion Simplify computation
Noise Simulation Gaussian / Salt & Pepper Evaluate denoising methods
Denoising Gaussian / Median / Bilateral filters Remove image noise
Edge Detection Auto-Canny Extract lane boundaries
Line Detection HoughLinesP & RANSAC Estimate lane lines
Evaluation PSNR & Line Coverage Quantify filtering and line quality

🧩 Pipeline Summary

  1. Load and preprocess image

    • Convert to grayscale
    • Add noise for evaluation
  2. Apply filters

    • Gaussian blur
    • Median blur
    • Bilateral filtering
  3. Measure PSNR

    • Quantify denoising performance
  4. Edge Detection

    • Use auto-threshold Canny edge detector
  5. Line Detection

    • Detect lines with Hough Transform
    • Fit lane lines with RANSAC (left/right lanes separately)
  6. Compare methods

    • Calculate coverage between detected lines and actual edges
    • Overlay RANSAC (red) vs Hough (green) on the image

πŸ“Š Example Results

Method Description Output
Gaussian Denoising Smooths random noise Example
Auto-Canny Adaptive edge detection Example
Hough vs RANSAC Line detection comparison Example

RANSAC (red) offers cleaner, more stable lane lines than Hough (green), especially in noisy or uneven lighting conditions.


🧰 Requirements

pip install opencv-python matplotlib numpy

Evaluation Metrics

PSNR (Peak Signal-to-Noise Ratio): Measures image quality after denoising.

Line Coverage (%): Percentage of edge pixels covered by detected lines (for both Hough and RANSAC).

πŸš€ Key Functions:

add_gaussian_noise() / add_salt_pepper() – Adds noise for testing

auto_canny() – Automatically selects Canny thresholds

detect_lines_houghp() – Detects lines using Hough transform

ransac_line_fit() / ransac_side() – Fits left/right lane lines robustly

line_coverage() – Quantifies detection quality

πŸ“š Concepts Demonstrated:

Noise modeling and denoising evaluation

Adaptive edge detection

Line detection using Hough and RANSAC

Quantitative evaluation with PSNR and coverage metrics

About

**A complete lane detection pipeline built with OpenCV, featuring denoising, adaptive edge detection (Auto-Canny), and robust line fitting using Hough Transform and RANSAC for accurate road lane extraction.**

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages