Project Details

Advanced Driver Assistance System (ADAS) integrating lane detection, vehicle tracking, and fatigue monitoring to prevent accidents in real-time.

Road Safety System

Table of Contents

List of all the sections in this post. Click to jump to that section.

Computer Vision-Based Advanced Driver Assistance System (ADAS)

1. Project Overview

This project involves the development of an Advanced Driver Assistance System (ADAS) designed to mitigate risks associated with driver distraction and adverse road conditions. The system integrates multiple computer vision algorithms to perform three critical tasks in real-time: lane detection and tracking, surrounding vehicle detection, and driver attention monitoring.

The primary objective was to implement an efficient solution capable of running on standard hardware (CPU), optimizing the trade-off between precision and latency.

2. Architecture and Tech Stack

The system’s core is built in Python, utilizing OpenCV as the main image processing engine. The architecture is divided into three concurrent modules:

  • Language: Python 3.x
  • Computer Vision: OpenCV (cv2), NumPy.
  • Deep Learning: YOLOv4-tiny (Convolutional Neural Network for object detection).
  • Classical Algorithms: Haar Cascades, Hough Transform, EM Algorithm (Expectation-Maximization).

3. Technical Implementation

Lane Detection Pipeline

A. Lane Detection (Hybrid Pipeline)

Instead of relying solely on deep neural networks (which are resource-intensive), I designed a robust pipeline combining classical computer vision with statistical techniques:

  1. Preprocessing and ROI: Dynamic definition of the Region of Interest (ROI) and application of Gaussian filters for noise reduction.
  2. Edge Detection: Implementation of the Canny algorithm with dynamic thresholds calculated based on the mean and standard deviation of pixel intensity in the current frame.
  3. Line Extraction: Application of the Probabilistic Hough Transform to identify straight line segments.
  4. Clustering with Expectation-Maximization (EM): This was the most significant technical challenge. To group scattered line segments into “left lane” and “right lane,” I implemented the EM algorithm. This allows for probabilistic modeling of the detected lines’ distribution, classifying them with greater accuracy than simple slope filtering and significantly improving detection stability between frames.

B. Vehicle Detection

For obstacle detection, I integrated the YOLOv4-tiny model. This “tiny” version was specifically selected to maintain a high frame rate (FPS) in environments without dedicated GPU acceleration. The system filters detections to exclusively identify the “car” class and calculates whether they are located within the danger zone defined by the detected lanes.

C. Driver Monitoring

An active safety module was implemented using Haar Cascades. The system processes the video feed from an internal camera to detect the driver’s face and eyes. By calculating the aspect ratio and temporal persistence, the algorithm triggers visual and auditory alerts if it detects signs of fatigue (closed eyes) or distraction (gaze diversion) exceeding a predefined time threshold.

4. Challenges and Results

One of the biggest challenges was temporal persistence. Road lines can be momentarily lost due to shadows or lighting changes. To solve this, I implemented deque data structures to maintain a memory of recent frames, smoothing the visualization and extrapolating the lane position when instantaneous detection fails.

The final result is a functional system capable of operating in real-time, providing augmented visual feedback (overlay on the video feed) and proactive safety alerts.

This project demonstrates how complex algorithms can be translated into practical, life-saving applications, all running on a standard laptop.