Skip to content

aarushdubey/VisionOps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

 ╦  ╦╦╔═╗╦╔═╗╔╗╔  ╔═╗╔═╗╔═╗
 β•šβ•—β•”β•β•‘β•šβ•β•—β•‘β•‘ β•‘β•‘β•‘β•‘  β•‘ β•‘β• β•β•β•šβ•β•—
  β•šβ• β•©β•šβ•β•β•©β•šβ•β•β•β•šβ•  β•šβ•β•β•©  β•šβ•β•

VisionOps β€” Real-Time Intelligence for Video Streams

Python 3.10+ OpenCV YOLOv8 FastAPI Streamlit


What is VisionOps?

VisionOps is a production-ready computer vision platform that performs real-time object detection using YOLOv8 and motion analysis using Optical Flow, with a live analytics dashboard. It ingests video streams (webcam or file), runs intelligent detection and motion analysis on every frame, and serves the results through a REST API and interactive dashboard. Designed to mirror industrial Operations Insight Platforms.


Features

  • 🎯 YOLOv8 Object Detection β€” Real-time COCO object detection with configurable confidence thresholds and class filtering
  • 🌊 Optical Flow Motion Analysis β€” Dense (Farneback) and Sparse (Lucas-Kanade) motion tracking with heatmap visualization
  • πŸ“Ί Live MJPEG Streaming β€” Annotated video stream accessible via browser or <img> tag
  • πŸ“Š Real-Time Dashboard β€” Dark-themed Streamlit dashboard with live metrics, charts, and event logs
  • ⚑ FastAPI Backend β€” High-performance REST API with auto-generated Swagger documentation
  • πŸ—ƒοΈ SQLite Event Logging β€” Persistent detection event storage with session statistics
  • πŸ–ΌοΈ Data Augmentation β€” Albumentations-based preprocessing and dataset augmentation tools
  • πŸ”§ Runtime Configuration β€” Update thresholds, flow modes, and video sources without restart
  • πŸ–₯️ GPU Acceleration β€” Automatic CUDA/MPS detection with CPU fallback

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          VisionOps Platform                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                      β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚ Video Source  β”‚     β”‚           Processing Pipeline            β”‚  β”‚
β”‚   β”‚              β”‚     β”‚                                          β”‚  β”‚
β”‚   β”‚  β€’ Webcam    │────▢│  OpenCV    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚  β”‚
β”‚   β”‚  β€’ Video     β”‚     β”‚  Capture ──▢│ YOLOv8 Detector    β”‚       β”‚  β”‚
β”‚   β”‚    File      β”‚     β”‚           β”‚ β”‚ (Object Detection) β”‚       β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚           β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚  β”‚
β”‚                        β”‚           β”‚          β”‚                    β”‚  β”‚
β”‚                        β”‚           β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚  β”‚
β”‚                        β”‚           β””β–Άβ”‚ Optical Flow        β”‚       β”‚  β”‚
β”‚                        β”‚             β”‚ (Motion Analysis)   β”‚       β”‚  β”‚
β”‚                        β”‚             β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚  β”‚
β”‚                        β”‚                      β”‚                    β”‚  β”‚
β”‚                        β”‚             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚  β”‚
β”‚                        β”‚             β”‚ Frame Merger        β”‚       β”‚  β”‚
β”‚                        β”‚             β”‚ (Overlay Composer)  β”‚       β”‚  β”‚
β”‚                        β”‚             β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚  β”‚
β”‚                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                               β”‚                      β”‚
β”‚                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚                          β”‚                    β”‚                 β”‚    β”‚
β”‚                  β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β” β”‚
β”‚                  β”‚ FastAPI      β”‚   β”‚ Streamlit     β”‚  β”‚ SQLite  β”‚ β”‚
β”‚                  β”‚ REST API     β”‚   β”‚ Dashboard     β”‚  β”‚ Logger  β”‚ β”‚
β”‚                  β”‚ + MJPEG      β”‚   β”‚ (Live UI)     β”‚  β”‚ (DB)    β”‚ β”‚
β”‚                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Installation

1. Clone the repository

git clone https://github.com/yourusername/VisionOps.git
cd VisionOps

2. Create a virtual environment (recommended)

python3 -m venv venv
source venv/bin/activate       # Linux/macOS
# or
venv\Scripts\activate          # Windows

3. Install dependencies

pip install -r requirements.txt

4. Verify installation

python -c "from ultralytics import YOLO; print('YOLOv8 OK')"
python -c "import cv2; print(f'OpenCV {cv2.__version__} OK')"
python -c "import fastapi; print('FastAPI OK')"

Note: The YOLOv8 nano model (yolov8n.pt) is automatically downloaded on first run (~6 MB).


Running the Project

Step 1: Start the FastAPI Backend

# From the VisionOps/ directory
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

The API will be available at http://localhost:8000
Swagger docs: http://localhost:8000/docs

Step 2: Start the Streamlit Dashboard

# In a separate terminal
streamlit run dashboard.py --server.port 8501

The dashboard will open at http://localhost:8501

Step 3: Test the /detect Endpoint

# Upload a sample image for detection
curl -X POST "http://localhost:8000/detect" \
     -F "file=@samples/test_image.jpg" \
     | python -m json.tool

Optional: Run Dataset Augmentation

# Place images in samples/ directory, then:
python augment_dataset.py --count 10

API Reference

Method Endpoint Description Response Type
GET / Health check β€” status + uptime JSON
GET /stream MJPEG live annotated video stream MJPEG Stream
POST /detect Upload image β†’ detections + motion score JSON
GET /stats Session statistics (frames, objects, FPS) JSON
GET /events Recent detection events (supports ?class_filter=) JSON
POST /config Update confidence, flow mode, source JSON

Example /detect Response

{
  "detections": [
    {
      "class_name": "person",
      "confidence": 0.87,
      "bbox": [120.5, 45.2, 380.1, 490.8]
    }
  ],
  "motion_score": 23.45,
  "object_counts": {"person": 1},
  "processing_time_ms": 45.23,
  "image_size": {"height": 720, "width": 1280}
}

Configuration

All settings are centralized in utils/config.py:

Parameter Default Description
MODEL_PATH yolov8n.pt YOLOv8 model weights file
CONFIDENCE_THRESHOLD 0.45 Minimum detection confidence
INPUT_SIZE (640, 640) Model input resolution
FLOW_MODE dense Optical flow mode (dense / sparse)
MAX_KEYPOINTS 100 Max keypoints for sparse flow
MOTION_THRESHOLD 2.0 Minimum magnitude for high-motion zones
DB_PATH db/visionops.db SQLite database file path
API_HOST 0.0.0.0 FastAPI bind address
API_PORT 8000 FastAPI port
STREAMLIT_PORT 8501 Streamlit dashboard port
STREAM_FPS_TARGET 30 Target frames per second for streaming
LOG_BATCH_SIZE 10 Events batched before DB write

Tech Stack

Technology Role
Python 3.10+ Core language
OpenCV Video capture, frame processing
Ultralytics YOLOv8 Object detection (nano model)
Optical Flow Motion analysis (Farneback + LK)
FastAPI REST API server
Streamlit Frontend dashboard
NumPy Array operations
Matplotlib Charts and visualizations
Albumentations Data augmentation
SQLite Event logging
Uvicorn ASGI server

Project Structure

VisionOps/
β”œβ”€β”€ main.py                  # FastAPI app entry point
β”œβ”€β”€ dashboard.py             # Streamlit dashboard
β”œβ”€β”€ augment_dataset.py       # Standalone augmentation script
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ detector.py          # YOLOv8 detection logic
β”‚   β”œβ”€β”€ motion.py            # Optical Flow (Dense + Sparse)
β”‚   β”œβ”€β”€ pipeline.py          # Combined detection + motion pipeline
β”‚   └── augment.py           # Albumentations preprocessing
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── routes.py            # FastAPI route definitions
β”œβ”€β”€ db/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── logger.py            # SQLite event logger
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ visualizer.py        # Drawing bboxes, flow, overlays
β”‚   └── config.py            # All configuration constants
β”œβ”€β”€ samples/                 # Sample videos/images for testing
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
└── .gitignore

Future Improvements

  • πŸš€ TensorRT Optimization β€” Export YOLOv8 to TensorRT for 5-10x faster inference on NVIDIA GPUs
  • πŸ“Ή Multi-Camera Support β€” Process multiple video streams simultaneously with load balancing
  • πŸ“‘ RTSP Stream Support β€” Connect to IP cameras and network video recorders
  • 🧠 Custom Model Training β€” Fine-tune YOLOv8 on domain-specific datasets via the augmentation pipeline
  • πŸ“Š Prometheus + Grafana β€” Enterprise-grade monitoring and alerting
  • 🐳 Docker Deployment β€” Containerized deployment with docker-compose
  • πŸ”” Alert System β€” Configurable alerts for specific object classes or motion thresholds
  • ☁️ Cloud Deployment β€” AWS/GCP deployment guides with auto-scaling

License

MIT License β€” see LICENSE for details.


VisionOps β€” Built with ❀️ using YOLOv8, OpenCV, FastAPI, and Streamlit

About

Real-Time Object Detection & Motion Analysis Platform - YOLOv8 + Optical Flow + FastAPI + Streamlit

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages