How zohaibkhan101/cammind works
Project Type and Purpose
• CamMind is a local, Python-based AI CCTV surveillance system with a minimal web UI.
• It captures a real-time video feed (webcam or IP camera), sends frames through a pretrained vision-language model (BLIP), overlays captions, applies judgment logic, logs events, and displays results in a browser.
File Structure
• Top-Level Files
• app.py → Flask application entrypoint and HTTP routing
• cctv_ai.py → Core video capture, ML inference, overlay & judgment logic
• requirements.txt → Python dependencies (Torch, Transformers, OpenCV, Flask)
• activity_log.txt → Plain-text log of alerts and events
• README.md → Project documentation
• templates/ → HTML templates (index.html) for the web UI
• No separate “frontend” folder – the single-page UI is served by Flask’s templates.
• No external microservices; everything runs locally.
README for Technical Stack and Flow
• Dependencies: Python 3.7+, OpenCV, PyTorch, Transformers.
• Runtime: “python aicctv.py” or “python app.py” (web UI).
• Judgement logic inside cctv_ai.py is customizable.
• Optional directories (snapshots/, logs/) for future persistence.
Main Components & Their Relationships
a. External Camera Source
– Webcam or IP camera
– Delivers raw video frames to the system
b. Flask Web Server (app.py)
– Serves index.html at “/”
– Exposes endpoints (e.g., “/start”, “/stop”) or WebSocket for frame streaming
c. Video Processing Module (cctv_ai.py)
– Reads frames from camera via OpenCV
– Feeds each frame to the BLIP model for captioning
– Applies “judgement logic” (e.g., suspicious activity rules)
d. ML Inference Engine (Vision-Language Model)
– BLIP model loaded via Hugging Face Transformers and Torch
– Returns text description for each frame
e. Overlay & Display
– Draws caption text on frame
– Streams annotated frames back to the browser
f. Logging & Storage
– Writes timestamped events to activity_log.txt (and optionally snapshots/)
– Could expand to SQLite or CSV in future
Architectural Patterns and Design Principles
• MVC-style separation:
• Model = BLIP model + judgment rules
• View = HTML template + overlaid video feed
• Controller = Flask routes + cctv_ai orchestrator
• Modular pipeline: capture → inference → logic → overlay → display → log
• Single deployable service (no external microservices)