Skip to main content
Back to ArchiveSYSTEMS ARCHIVE
07 // Edge Computer Vision NVRMicrosoft BWB Finalist • Live

HazardLens

Enterprise NVR and real-time AI threat detection console pairing dual YOLOv8 models (fire/smoke + crowd surge) with decoupled native MJPEG streaming (12–15 FPS), single-port Nginx reverse proxying, Hindi Edge-TTS neural voice alerts, and Resend email dispatch.

RoleLead Edge-AI & Systems Engineer
ContextBuild With Bharat 1.0 (Microsoft) Finalist • Live
Live DemoSource Code
Native Stream
12–15 FPS
Fire Filter
0.85 Conf
Test Suite
59 Tests
INTERACTIVE SYSTEM SIMULATORLIVE CLIENT DEMO
DUAL YOLOv8 • CONF ≥ 0.85NATIVE MJPEG • 12–15 FPS
ENGINE 1: CUSTOM YOLOv8 (best.pt)FIRE / SMOKE
चेतावनी: सेक्टर A में आग/धुआं पाया गया है। तुरंत बाहर निकलें।
BREACH ≥ 0.85 • EDGE-TTS HINDI (hi-IN-SwaraNeural) + RESEND
NGINX SINGLE-PORT :850159 TESTS
01 // THE BOTTLENECK

Problem Space

Standard CCTV requires passive human monitoring, while rendering live computer-vision streams inside Streamlit's script-rerun loop causes UI dimming, WebSocket queue stalls, and frozen frames.

02 // THE SYSTEM

Production Architecture

Decouples video capture (CameraWorker), dual YOLOv8 inference (InferenceWorker), and native multipart MJPEG streaming (:8502) from Streamlit (:8503) behind a single-port Nginx reverse proxy (:8501) on Azure Container Apps.

Execution Pipeline

  1. STAGE 01

    Zero-Buffer CameraWorker

    Ingests IP webcam or Cloudflare tunnel feeds via FFmpeg nobuffer flags with automatic keep-alive /shot.jpg fallback.

  2. STAGE 02

    Dual YOLOv8 InferenceWorker

    Runs custom fire/smoke model (best.pt, conf >= 0.85) and person counter (yolov8n.pt, limit 5) asynchronously at imgsz=320.

  3. STAGE 03

    Native MJPEG + Nginx Proxy

    ThreadingHTTPServer streams ~15 FPS JPEG over /stream while Nginx unifies UI WebSockets and video under one HTTPS origin with proxy_buffering off.

  4. STAGE 04

    1Hz Alert FSM & Hindi TTS

    1Hz @st.fragment drives Edge-TTS Hindi voice alerts (hi-IN-SwaraNeural) with 3s clear-grace shutoff, 60s PIN-gated silence, and queued Resend email alerts.

Key Engineering Trade-Offs & Decisions

  • Moved live video outside Streamlit reruns into a dedicated MJPEG server, achieving steady 12–15 FPS with zero DOM flicker.
  • Added SSRF URL validation, operator PIN controls, and SHA-256 model integrity checks in utils/security.py.
  • Replaced transitive GUI opencv-python with opencv-python-headless and CPU-only PyTorch wheels under a non-root container user.
  • Verified audio loop resets, email cooldown/retries, and security guards across 59 pytest tests.

Tech Stack

YOLOv8OpenCVStreamlitNginxEdge-TTSResendDockerAzure ACAPytest
Deployment & Runtime

Live on Azure Container Apps (2 vCPU / 4 GiB, scale-to-zero, single-port Nginx :8501) via ghcr.io/tusharsingh-sde/hazardlens:v1.

Open-source repo: PRs, issues, and feature collabs are always welcome on GitHub.

NEXT CASE STUDY
08 — Antriksha Search Engine (ASE)
Open Next