How karan96108/livecount works
Project type and purpose
• This is a monolithic full-stack web application written in Python/Flask for real-time emotion detection using OpenCV and DeepFace.
• It captures video from a webcam, runs an emotion-classification model, counts people, monitors FPS, and streams the annotated video to a browser UI.
File structure
• Top-level:
• test.py – main Flask app and video-capture loop
• wsgi.py – entrypoint for WSGI servers (e.g., Gunicorn)
• templates/index.html – single-page frontend UI
• Speech_Emotion_Recognition_Model.h5 and tmp_pretrained_models/… – pre-trained model artifacts
• requirements.txt, runtime.txt – dependency and runtime specifications
• render.yaml – deployment config for Render.com
• .devcontainer/ – development container settings
• Patterns:
• MVC-style separation: templates/ (View), test.py (Controller), model files (Model)
• Single service (no microservices)
Key insights from README
• Real-time face detection + emotion classification + people count + FPS
• Startup: “python test.py,” serve at localhost:5000
Main components
a. Client (Browser) – displays UI and video stream
b. Web Server (Flask) – handles HTTP endpoints and video streaming
c. Video Capture Module (OpenCV) – reads frames from webcam
d. Emotion Detection Module (DeepFace + .h5 model) – performs inference
e. Analytics Module – counts people, computes FPS
f. Pre-trained Model Storage – Speech_Emotion_Recognition_Model.h5 and tmp_pretrained_models
g. External Dependencies – OpenCV, DeepFace, Flask
Relationships & data flows
• Browser → HTTP GET “/” → Flask serves index.html
• Browser ↔ HTTP Video Stream (e.g., MJPEG) ← Flask wraps OpenCV frames
• Flask → invoke Emotion Detection Module on each frame
• Emotion Detection Module → returns emotion label
• Analytics Module → updates people count & FPS
• Flask → overlays results on frames → streams to Browser
Architectural patterns & design principles
• MVC:
• View = templates/index.html (UI)
• Controller = test.py routing + frame loop
• Model = pre-trained .h5 + hyperparameters
• Single-process event loop: video capture, inference, streaming all in one service
• Config as code: render.yaml for deployment, .devcontainer for consistency
Technology & frameworks to annotate
• Python 3.x (runtime.txt)
• Flask (wsgi.py + test.py)
• OpenCV (cv2.VideoCapture)
• DeepFace (emotion-recognition pipeline)
• Model file: Speech_Emotion_Recognition_Model.h5
• Deployment: Render.com (render.yaml), Docker devcontainer