Skip to content

mwasifanwar/NeuroDrive-Vision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงญ NeuroDrive-Vision

โš™๏ธ Advanced AI-Powered Lane Detection & Road Perception Framework


๐Ÿš€ Overview

NeuroDrive-Vision ๐Ÿš—๐Ÿ’ก is an AI-powered lane detection and road perception system engineered to replicate the core vision intelligence of autonomous vehicles.
It brings together the precision of classical computer vision and the robustness of modern modular architecture, enabling both real-time performance and research-grade extensibility.

๐Ÿง  Core Philosophy

The goal of NeuroDrive-Vision is not just to detect lanes โ€” but to perceive the road like a driver would, using a structured vision pipeline that interprets motion, geometry, and perspective in a consistent, explainable way.

Each stage of the system works as an intelligent, pluggable module that you can enhance, swap, or train for different environments (urban roads, highways, or race tracks).
This makes the framework perfect for:

  • ๐Ÿ”ฌ Research & prototyping of autonomous driving perception stacks
  • ๐ŸŽ๏ธ Real-time applications for road boundary detection
  • ๐Ÿงฉ Educational demonstrations in AI, OpenCV, and perception systems

๐ŸŒŸ Key Highlights

๐Ÿ’ก Feature ๐Ÿงพ Description
โš™๏ธ End-to-End Pipeline From raw frame to annotated lane overlay โ€” each step modularized and independently testable.
๐Ÿงฉ Adaptive ROI Mapping Automatically adjusts to different video resolutions and camera perspectives.
๐Ÿง  Exponential Smoothing (EMA) Maintains lane stability by learning temporal motion between frames.
๐Ÿš€ Real-Time Performance Optimized OpenCV operations achieve 30โ€“60 FPS on modern CPUs.
๐ŸŒ Dual Interface Support Command-Line (CLI) for automation and Gradio Web App for live visual demos.
๐Ÿ“ฆ Dockerized Deployment Build once, deploy anywhere โ€” consistent behavior across environments.
๐Ÿงฐ Research-Grade Modularity Every component is decoupled, documented, and open for fine-tuning or replacement.

๐Ÿง  Developed With

  • ๐Ÿงฉ Python 3.11+ for modern type-safe design
  • ๐Ÿงฎ NumPy for high-speed numerical computation
  • ๐Ÿ‘๏ธ OpenCV for robust image transformation and edge processing
  • ๐Ÿ’ป Gradio for web-based visualization and user interaction
  • ๐Ÿงฑ Docker for deployment and scalability

๐Ÿง  Developed with โค๏ธ by mwasifanwar
๐Ÿ”— A vision system that learns, adapts, and drives.


๐Ÿงฉ Architecture

The architecture of NeuroDrive-Vision is designed for clarity, extensibility, and real-time flow. Each module performs a focused task and hands off its output to the next โ€” resulting in a clean and efficient processing pipeline.


๐Ÿง  High-Level System Flow

๐Ÿšฆ 1. Frontend Layer

  • ๐Ÿ–ฅ๏ธ CLI Interface: Enables headless operation for batch video processing and automation.
  • ๐ŸŒ Gradio Web Demo: Provides a user-friendly browser interface for real-time experimentation.
  • ๐Ÿ’ฌ Both interfaces invoke the same backend pipeline ensuring identical detection logic.

โš™๏ธ 2. Core Processing Layer

  • ๐Ÿงฉ The heart of the system, where all computer vision operations happen.
  • Comprised of modular stages:
    • ๐ŸŸฃ Edge Detection (Canny Algorithm) โ€” Extracts fine boundaries and gradients from raw frames.
    • ๐ŸŸข Region of Interest (ROI) Extraction โ€” Masks irrelevant regions, focusing on lane-relevant areas.
    • ๐ŸŸก Probabilistic Hough Transform โ€” Converts edge data into line candidates using polar coordinates.
    • ๐Ÿ”ต Line Grouping & Averaging โ€” Filters and merges left/right lane boundaries.
    • ๐ŸŸ  Exponential Smoothing (EMA) โ€” Stabilizes detection across time for a fluid driving experience.

๐Ÿงฐ 3. Shared Utilities & Configuration

  • ๐Ÿงพ Config Manager โ€” Stores and handles parameters (thresholds, kernel sizes, ROI shapes, etc.).
  • ๐Ÿ’พ Input/Output Helpers โ€” Manage frame capture, video writing, and batch processing.
  • โš™๏ธ Tracker Module (EMA-based) โ€” Tracks lane continuity between consecutive frames.
  • ๐Ÿงฎ Math & Geometry Utilities โ€” Support transformations and vector calculations.

๐Ÿ“ฆ 4. Output & Visualization

  • ๐ŸŽฅ Annotated video frames with smooth blue lane overlays.
  • ๐Ÿ“Š Optional visualization of each processing stage (edges, ROI, smoothed lanes).
  • ๐ŸŒ Displayed interactively via Gradio or saved locally.

๐Ÿงฌ Architecture Diagram

System Architecture Diagram


๐Ÿ” Data Flow Summary

๐Ÿ”ข Step ๐Ÿง  Process ๐ŸŽฏ Output
1๏ธโƒฃ Raw frame input via OpenCV RGB frame
2๏ธโƒฃ Canny Edge Detection Binary edge map
3๏ธโƒฃ Region of Interest Extraction Masked edge image
4๏ธโƒฃ Hough Transform Line segments
5๏ธโƒฃ Line Averaging & Filtering Merged lane candidates
6๏ธโƒฃ Exponential Smoothing Stable, smoothed lanes
7๏ธโƒฃ Overlay Rendering Annotated driving frame

โš™๏ธ Architectural Philosophy

๐Ÿ’ฌ "Each module in the NeuroDrive pipeline is designed to think like a neuron โ€” specialized, fast, and connected."

  • ๐Ÿง  Parallelizable โ€” Future GPU or TensorRT integration ready.
  • ๐Ÿงฉ Plug-and-Play Modules โ€” Swap Canny with Sobel, or add a DNN-based lane segmentation head.
  • ๐Ÿ”„ Bidirectional Data Flow โ€” Supports feedback loops for model fine-tuning and adaptive thresholds.
  • ๐Ÿงฐ Layer Independence โ€” Frontend, core, and utilities operate independently with defined interfaces.

โœจ In essence:
The Architecture is built for clarity, speed, and innovation โ€” enabling researchers, developers, and enthusiasts to extend the system into a full-scale perception module for self-driving vehicles.

โœจ Key Features

NeuroDrive-Vision isnโ€™t just a basic lane detector โ€” itโ€™s a complete AI perception framework โš™๏ธ designed for performance, adaptability, and real-world scalability.
Every feature is built with a clear purpose: to bridge the gap between academic research and production-grade autonomous systems.


๐Ÿงฉ 1. Modular Vision Pipeline

โ€œEach component is independent yet perfectly synchronized.โ€

  • Every stage โ€” from edge detection to smoothing โ€” exists as a self-contained module.
  • Developers can easily modify, replace, or extend parts of the pipeline without breaking the system.
  • Ideal for experimentation, allowing quick swaps (e.g., Canny โ†’ Sobel โ†’ Deep CNN lanes).

๐Ÿ”น Benefits:

  • Easy debugging and testing per stage.
  • Seamless integration for AI/ML add-ons.
  • Encourages clean and scalable architecture.

๐Ÿ—บ๏ธ 2. Adaptive ROI Masking (Dynamic Field of View)

โ€œA vision system that adjusts to the road like a human eye.โ€

  • The Region of Interest (ROI) dynamically scales with input frame dimensions.
  • Automatically aligns to different camera positions and angles โ€” from dashboard cams to drones.
  • Guarantees the algorithm focuses only on lane-relevant zones, filtering out sky, mountains, or irrelevant objects.

๐ŸŽฏ Benefits:

  • Works across any camera setup or road width.
  • Reduces computation and false positives.
  • Improves efficiency on embedded systems (Jetson, Pi, etc.).

๐Ÿ“‰ 3. EMA Smoothing (Temporal Stability)

โ€œBecause roads move fast, but your detection shouldnโ€™t flicker.โ€

  • Implements an Exponential Moving Average (EMA) smoother for both left and right lane coordinates.
  • Reduces noise and frame-to-frame jitter caused by sensor variations or uneven edges.
  • Mimics temporal prediction used in real autonomous vehicles for lane persistence.

๐Ÿง  Benefits:

  • Delivers buttery-smooth line motion even on shaky footage.
  • Helps maintain consistent visual alignment.
  • Future-ready for integration with Kalman Filters or LSTM-based tracking.

๐Ÿง  4. Dual Interface System (CLI + Web UI)

โ€œPower for engineers, simplicity for users.โ€

  • ๐Ÿ’ป Command-Line Interface (CLI): Automate and batch-process videos with flexible argument controls.
  • ๐ŸŒ Gradio Web Demo: Experiment interactively, visualize outputs, and compare results live.
  • Both use the same backend logic, ensuring identical performance and results.

โœจ Benefits:

  • Developer-friendly automation via CLI.
  • Non-technical users can explore the model visually.
  • Excellent for demos, research papers, and workshops.

โšก 5. Real-Time Capable

โ€œOptimized to see, think, and respond โ€” instantly.โ€

  • Built with pure NumPy and OpenCV vectorized operations for speed.
  • Capable of processing 30โ€“60 FPS on standard hardware.
  • Efficient memory management ensures no dropped frames or lag.

๐Ÿš€ Benefits:

  • Ideal for real-time applications like robotics or ADAS prototypes.
  • No external dependencies on GPUs or heavy models.
  • Runs on laptops, Raspberry Pi, or embedded ARM devices.

๐Ÿงฑ Project Structure

The NeuroDrive-Vision repository is organized to maintain clarity, scalability, and modularity.
Each folder serves a well-defined purpose โ€” from pipeline logic to front-end interaction, ensuring seamless development, testing, and deployment.


๐Ÿ“‚ Directory Overview

Click to view directory tree

neurodrive-vision/ โ”œโ”€ ๐Ÿ“ src/ # ๐Ÿง  Core source code for processing & orchestration โ”‚ โ”œโ”€ โš™๏ธ config.py # Configuration dataclasses and tunable parameters โ”‚ โ”œโ”€ ๐Ÿ”„ pipeline.py # Main orchestrator handling frame-by-frame logic โ”‚ โ”œโ”€ ๐Ÿงฐ utils.py # Shared helper functions (math, blending, etc.) โ”‚ โ”œโ”€ ๐Ÿ’พ io.py # Input/output utilities for videos & images โ”‚ โ”œโ”€ ๐ŸŽฏ tracker.py # EMA-based lane tracker and smoother โ”‚ โ””โ”€ ๐Ÿ“ vision/ # Vision processing submodules โ”‚ โ”œโ”€ ๐Ÿ‘๏ธ edges.py # Canny edge detection module โ”‚ โ”œโ”€ ๐Ÿ—บ๏ธ roi.py # Dynamic Region-of-Interest (ROI) extraction โ”‚ โ”œโ”€ ๐Ÿ“ hough.py # Probabilistic Hough transform logic โ”‚ โ”œโ”€ ๐Ÿ“‰ lines.py # Line grouping, filtering, and averaging โ”‚ โ””โ”€ ๐Ÿ” smoothing.py # Exponential lane smoothing algorithm โ”‚ โ”œโ”€ ๐Ÿ“ apps/ # ๐Ÿ’ป Interfaces for different usage modes โ”‚ โ”œโ”€ ๐Ÿงพ cli.py # Command-line interface (batch mode) โ”‚ โ””โ”€ ๐ŸŒ gradio_app.py # Web interface (Gradio demo dashboard) โ”‚ โ”œโ”€ ๐Ÿ“ assets/ # ๐Ÿงฉ Visual and data assets โ”‚ โ”œโ”€ ๐Ÿ“ figures/ # ๐Ÿ“Š Documentation figures & output samples โ”‚ โ”‚ โ”œโ”€ ๐Ÿงฌ architecture.png # Complete system architecture diagram โ”‚ โ”‚ โ”œโ”€ ๐ŸŸฃ roi_mask_demo.png # ROI region visualization โ”‚ โ”‚ โ”œโ”€ โšช canny_edges_full.png # Full-frame edge detection result โ”‚ โ”‚ โ”œโ”€ ๐ŸŸข canny_edges_roi.png # ROI-filtered Canny result โ”‚ โ”‚ โ””โ”€ ๐Ÿ”ต lane_overlay_result.png # Final lane overlay output โ”‚ โ””โ”€ ๐ŸŽž๏ธ sample_video.mp4 # Example driving video for testing โ”‚ โ”œโ”€ ๐Ÿ“ tests/ # ๐Ÿงช Unit testing modules โ”‚ โ””โ”€ ๐Ÿงฉ test_edges.py # Unit test for edge detection validation โ”‚ โ”œโ”€ ๐Ÿ“œ requirements.txt # ๐Ÿ“ฆ Python dependencies โ”œโ”€ ๐Ÿณ Dockerfile # ๐Ÿงฑ Docker image for containerized deployment โ””โ”€ ๐Ÿงพ README.md # ๐Ÿ“˜ Project documentation

โš™๏ธ Installation

๐Ÿช„ Quick Setup โ€” Get started in under a minute!

Clone the repository and install dependencies:

1๏ธโƒฃ Clone the repository

git clone https://github.com/mwasifanwar/neurodrive-vision.git

2๏ธโƒฃ Navigate into the project folder

cd neurodrive-vision

3๏ธโƒฃ Create a virtual environment

python -m venv .venv

4๏ธโƒฃ Activate the environment

๐ŸชŸ Windows

.venv\Scripts\activate

๐Ÿง macOS / Linux

source .venv/bin/activate

5๏ธโƒฃ Install all required dependencies

pip install -r requirements.txt

๐Ÿ–ผ๏ธ Visual Results

Every stage of NeuroDrive-Visionโ€™s processing pipeline produces a meaningful transformation in how the system perceives the road.
These visuals are stored in the assets/figures/ folder โ€” each representing a critical step from raw frame to fully annotated output.

They not only help debug and analyze the perception pipeline but also provide a transparent view of the modelโ€™s visual reasoning process.


๐Ÿ“Š Processing Stages Overview

๐Ÿงฉ Stage ๐Ÿ“– Description ๐Ÿ–ผ๏ธ Sample Output
๐ŸŸฃ ROI Mask The Region of Interest isolates only the driving-relevant area (a triangular mask that focuses on the lane zone). Everything outside this region is darkened, ensuring efficient and accurate lane detection.

ROI Mask Visualization

โšช Canny Edges The raw edge map generated using the Canny Edge Detector โ€” highlights all strong gradients and lane boundaries. This serves as the foundation for subsequent lane extraction.

Canny Edge Detection

๐ŸŸข Masked Edges (Canny + ROI) The intersection of Canny edges with the ROI mask. This focuses computation only on edges inside the defined lane region, eliminating irrelevant patterns (trees, sky, etc.).

Canny Edges within ROI

๐Ÿ”ต Final Overlay The final composited frame. The detected lane lines (left and right) are drawn in blue with smooth transitions using the EMA-based smoothing algorithm, resulting in stable and visually pleasing motion.

Final Annotated Lane Output


๐Ÿ” How to Access These Outputs

All processed visualization examples are saved under:

๐Ÿ“ assets/ โ”œโ”€ ๐Ÿ“ figures/ โ”‚ โ”œโ”€ roi_mask_demo.png # Step 1 - ROI visualization โ”‚ โ”œโ”€ canny_edges_full.png # Step 2 - Full edge map โ”‚ โ”œโ”€ canny_edges_roi.png # Step 3 - ROI-filtered edge result โ”‚ โ””โ”€ lane_overlay_result.png # Step 4 - Final detected lane overlay

โš™๏ธ Configuration

NeuroDrive-Vision is built with a fully modular and configurable core, allowing you to fine-tune every stage of the perception pipeline with ease.
All parameters are organized inside src/config.py ๐Ÿงฉ โ€” designed using Python dataclasses for clarity and type safety.

Each configuration block controls a specific part of the pipeline, ensuring that developers and researchers can quickly experiment with different thresholds, filters, and visual effects.


๐Ÿงพ Configuration Categories

๐Ÿ”ง Category โš™๏ธ Parameters ๐Ÿง  Description
๐Ÿฉถ Canny blur_kernel, low_thresh, high_thresh Controls Gaussian blur size and edge detection thresholds for refining sensitivity to road boundaries.
๐Ÿ“ Hough Transform rho, theta, threshold, min_line_len, max_line_gap Adjusts line detection precision using polar coordinates; fine-tune for lane segment smoothness and continuity.
๐Ÿ—บ๏ธ Region of Interest (ROI) bottom_left, top_mid, bottom_right Defines the triangular field of view where lanes are expected โ€” adaptive to video resolution.
๐Ÿ“‰ Smoothing (EMA) ema_alpha Controls how smoothly lane positions evolve across frames โ€” higher = faster response, lower = more stable.
๐ŸŽจ Drawing Settings line_color, line_thickness, blend_alpha Customizes lane overlay aesthetics including color (BGR), thickness, and transparency blending ratio.

๐Ÿ”ฎ Future Enhancements

NeuroDrive-Vision is not a static project โ€” itโ€™s an evolving AI research platform ๐Ÿง , designed to keep growing alongside advancements in autonomous perception and computer vision.
The roadmap focuses on transforming it from a classical CV-based system into a hybrid AI perception framework that seamlessly merges geometry, deep learning, and temporal intelligence.


๐ŸŒŸ Vision Statement

โ€œTo bridge the gap between classical computer vision and deep learning โ€” creating a scalable, interpretable, and real-time perception system for next-generation autonomous driving.โ€


๐Ÿง  Planned Upgrades & Research Roadmap

๐Ÿš€ Feature ๐Ÿ’ก Purpose & Description
๐ŸŸฉ YOLOv8 / SegFormer Integration Integrate modern deep-learning-based segmentation models for pixel-level lane understanding. This enhancement will enable robust lane detection in complex environments (rain, glare, snow, or night driving).
๐Ÿงฎ Kalman Filter Tracking Introduce state-space tracking and prediction to enhance temporal lane stability. This addition will allow predictive lane behavior even when edges are temporarily obscured by vehicles or road artifacts.
๐ŸŒ€ Curvature Estimation Module Implement a lane curvature and slope analysis algorithm to calculate real-time bending angles of roads, ideal for adaptive steering simulations and robotics control systems.
โšก FastAPI Microservice Deployment Package the detection pipeline as a RESTful API powered by FastAPI, enabling real-time streaming, mobile integration, and deployment in autonomous simulation environments (CARLA, Webots, etc.).
๐Ÿค– ROS2 (Robot Operating System) Compatibility Build ROS2 nodes for plug-and-play integration with robotics systems, ensuring seamless synchronization with camera feeds, IMU sensors, and LiDAR data for holistic road understanding.

๐Ÿงฉ Beyond the Roadmap

The long-term vision for NeuroDrive-Vision goes beyond simple lane tracking โ€” aiming to evolve into a full-scale AI Driving Perception Suite featuring:

  • ๐Ÿงญ Multi-Lane Tracking with probabilistic lane identity association
  • ๐Ÿงฑ 3D Lane Reconstruction using stereo depth or LiDAR fusion
  • ๐Ÿง  Reinforcement Learning-Based Control Feedback Loops
  • โ˜๏ธ Cloud-Synced Dataset Labeling for Model Retraining
  • ๐Ÿ”„ Self-Calibrating Parameter Optimization Engine

๐Ÿ’ฌ Why This Matters

These planned enhancements will transform NeuroDrive-Vision from a research tool into a real-world deployable perception backbone, capable of powering:

  • ๐Ÿš— Autonomous Driving Simulators (CARLA, AirSim)
  • ๐Ÿค– Robotic Navigation Systems
  • ๐Ÿง  AI-Powered Traffic Analysis Tools
  • ๐Ÿ›ฐ๏ธ Smart-City Vision Applications


โœจ Author

Muhammad Wasif
AI/ML Developer @ Effixly AI

LinkedIn Email Website

โญ *"A machine that can see the road is not just detecting pixels โ€” > itโ€™s learning to understand purpose, motion, and possibility."*


About

An advanced, modular lane detection and road perception framework built with OpenCV, NumPy, and Gradio, engineered for real-time autonomous driving research. It features adaptive ROI mapping, probabilistic Hough transformation, EMA-smoothed lane tracking, and an interactive Gradio demo UI.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages