How mwasifanwar/smartcity-vision works
Project type and purpose
• This is a full-stack computer-vision system (“smartcity-vision”) for real-time smart-city management.
• It ingests CCTV feeds and satellite imagery, runs ML‐powered detectors and analyzers (traffic, crowd, parking, pedestrians), exposes results via a FastAPI service, and drives an interactive dashboard.
File structure
• Top-level directories:
• api: FastAPI server and endpoint definitions
• core: processing modules (object_detector, traffic_analyzer, crowd_density, etc.)
• dashboard: front-end app (likely Streamlit or Flask)
• data: sample data for testing or demo
• models: ML model wrappers (YOLO, custom)
• utils: shared helpers (config loader, video processing, geo utilities, visualization)
• tests: unit tests for detectors and analyzers
• Key scripts:
• main.py: orchestrates end-to-end pipeline (ingestion → processing → serving)
• run_dashboard.py: launches the dashboard GUI
• config.yaml + utils/config_loader.py: centralized configuration
README for additional insights
• Purpose: real-time detection of traffic patterns, crowd density, parking availability, and pedestrian flow.
a. Main components
1. Data Sources
– CCTV camera streams
– Satellite imagery service
2. Video Ingestion & Preprocessing
– utils/video_processor.py
– utils/config_loader.py (config.yaml)
3. Core Analysis Pipeline
– core/object_detector.py (uses models/yolo_model.py & custom_models.py)
– core/traffic_analyzer.py
– core/crowd_density.py
– core/parking_analyzer.py
– core/pedestrian_tracker.py
4. Data Storage (optional)
– In-memory queues or time-series DB (not in code but you may annotate)
5. API Layer
– api/fastapi_server.py & api/endpoints.py
6. Dashboard Frontend
– dashboard/app.py (run via run_dashboard.py)
7. Utilities
– utils/geo_utils.py, utils/visualization.py
b. Relationships & Data Flow
– Ingestion → Core Analysis modules (object detection first → specialized analyzers)
– Analysis outputs → API Layer (exposed as REST/WebSocket endpoints)
– Dashboard polls/subscribes to API to render live metrics & maps
– Configuration flows into Ingestion & API at startup via config_loader
c. Architectural Patterns & Design Principles
– Modular Pipeline: each analyzer is a separate module that can be chained or replaced
– Service-Oriented: clear separation between processing logic (core) and serving logic (api + dashboard)
– Dependency Injection: config_loader centralizes parameters for all modules
– Testable Units: core and models directories have accompanying tests
d. Key Technologies & Frameworks
– Python 3.x, FastAPI for the REST layer
– YOLO (and custom) models for object detection (likely using PyTorch or TensorFlow)
– Video processing via OpenCV or similar (inside utils/video_processor.py)
– Dashboard framework (Flask/Streamlit) in dashboard/app.py