ShivamMathtech/Lane-Detection-Studio

A complete local application for uploading road videos, detecting lane boundaries, saving annotated videos, and downloading lane-analysis reports.

★ 1Forks 0PythonGitHub ↗Compare

README

Lane Detection Studio

A complete local application for uploading road videos, detecting lane boundaries, saving annotated videos, and downloading lane-analysis reports.

Main features

  • Simple responsive upload dashboard
  • Drag-and-drop video upload
  • MP4, AVI, MOV, MKV, WebM and M4V support
  • CPU-based OpenCV lane detection; no GPU required
  • Green lane overlay and detected lane-center line
  • Vehicle offset estimation
  • Centered, left-drift and right-drift status
  • Processing progress and persistent job history
  • Saved annotated video output
  • Downloadable JSON analysis report
  • SQLite metadata storage
  • FastAPI Swagger documentation
  • Optional FFmpeg H.264 optimization when FFmpeg is installed

Project structure

lane-detection-studio/
├── backend/
│   ├── app/
│   │   ├── services/lane_detector.py
│   │   ├── services/video_processor.py
│   │   ├── config.py
│   │   ├── database.py
│   │   ├── main.py
│   │   ├── models.py
│   │   └── schemas.py
│   ├── tests/
│   └── requirements.txt
├── frontend/
│   ├── index.html
│   ├── app.js
│   └── styles.css
├── storage/
│   ├── input/
│   ├── output/
│   └── reports/
├── Dockerfile
├── docker-compose.yml
├── run_linux.sh
└── run_windows.bat

Run on Windows

1. Open PowerShell inside the project folder

cd lane-detection-studio

2. Create and activate a virtual environment

py -m venv .venv
.\.venv\Scripts\Activate.ps1

When PowerShell blocks activation, run this once in the same terminal:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Then activate again.

3. Install dependencies

python -m pip install --upgrade pip
pip install -r backend\requirements.txt

4. Start the application

uvicorn app.main:app --app-dir backend --reload --host 0.0.0.0 --port 8000

Open:

  • Application: http://localhost:8000
  • Swagger API: http://localhost:8000/docs

You can also double-click run_windows.bat after Python is installed.

Run on Linux or macOS

cd lane-detection-studio
chmod +x run_linux.sh
./run_linux.sh

Open http://localhost:8000.

Run with Docker

docker compose up --build

Open http://localhost:8000.

Application workflow

  1. Upload a front-facing road video.
  2. The API saves the original video under storage/input.
  3. OpenCV processes each frame using edge detection, a road region of interest, Hough line detection and temporal smoothing.
  4. The system writes an annotated output under storage/output.
  5. A JSON report is saved under storage/reports.
  6. The web dashboard stores and displays processing history through SQLite.

Report fields

The report includes:

  • Frames processed
  • Video FPS and duration
  • Lane-detection rate
  • Average confidence
  • Average vehicle offset
  • Maximum absolute offset
  • Lane-departure event count
  • A one-second sampled status timeline

Detection limitations

This CPU pipeline works best when:

  • The camera faces forward and remains stable.
  • Lane markings are visible.
  • The road is reasonably illuminated.
  • The vehicle is travelling on a mostly straight or moderately curved road.

Performance can decrease during heavy rain, night driving, sharp turns, worn lane markings, shadows, construction zones and camera vibration. This project is intended for learning, prototyping and research; it is not a certified advanced driver-assistance system.

API routes

Method Route Purpose
GET /api/health API health check
POST /api/videos/upload Upload and queue a video
GET /api/jobs List saved jobs
GET /api/jobs/{job_id} Read one job
GET /api/jobs/{job_id}/report Download JSON report
DELETE /api/jobs/{job_id} Delete a job and files

Test the detector

cd backend
python -m pytest -q

Improving accuracy later

The LaneDetector service can be replaced by a deep-learning model such as a segmentation network while keeping the same upload, storage, API and dashboard layers. For long videos or multiple simultaneous users, move processing from FastAPI background tasks to Celery or RQ with Redis.

Contributors

ShivamMathtech

Issues