A comprehensive multi-modal customer analytics system that combines person detection, facial emotion recognition, body language analysis, demographic classification, and temporal tracking for retail and service environments.
This system provides real-time customer behavior analysis at service counters using a single RGB camera. It combines multiple state-of-the-art models to deliver comprehensive analytics:
- Satisfaction Score (0-1): Multi-modal fusion of facial emotions and body language
- Processing Time: Accurate session tracking in Region of Interest (ROI)
- Demographics: Age group and gender classification
- Engagement Metrics: Emotion timeline, body posture, and attention tracking
The system is optimized for real-time performance with intelligent frame skipping and model caching.
- YOLO v8/v11: State-of-the-art real-time person detection
- Region of Interest (ROI): Automatic detection of counter interaction zone
- Session Tracking: Precise timing when customers enter/exit ROI
- Adaptive ROI: Configurable ROI size (20% default, 40% for specific cameras)
- FER Library: 7-emotion classification (happy, sad, angry, surprise, fear, disgust, neutral)
- MTCNN Face Detection: High-accuracy face localization
- Temporal Smoothing: Emotion timeline analysis for robust satisfaction scoring
- ROI-Focused: Only analyzes emotions when person is in service area
- TFLite Model: Custom-trained 9-class body posture classifier
- Classes: Happy, Sad, Angry, Surprised, Confused, Tension, Excited, Pain, Depressed
- Satisfaction Mapping: Converts posture to 0-100 satisfaction score
- Lightweight: Optimized for real-time edge inference
-
Gender Classification:
- Model:
rizvandwiki/gender-classification(Hugging Face) - Accuracy: ~92% on UTKFace dataset
- Classes: Male, Female
- Model:
-
Age Classification:
- Model:
nateraw/vit-age-classifier(Vision Transformer) - Accuracy: ~77% on UTKFace dataset
- Classes: 0-2, 3-9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70+
- Model:
- Entry/Exit Detection: Automatic session start/stop
- Multiple Sessions: Tracks total time across all ROI entries
- Millisecond Precision: Accurate timing for analytics
- Session Metadata: Duration, entry count, average time per session
- Satisfaction Rate: Weighted combination of facial emotions (positive/negative)
- Body Language Integration: Posture scores complement emotion analysis
- Temporal Context: Earlier emotions weighted differently than recent ones
- Confidence Scoring: Model predictions include confidence levels
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Video Input (Camera/File) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOLO Person Detection (YOLOv8n) β
β β’ Detects persons in frame β
β β’ Calculates ROI overlap (IOU) β
β β’ Frame skipping: Every 3rd frame β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
Person in ROI?
β
ββββββββββββββ΄βββββββββββββ
β β
YES NO
β β
βΌ βΌ
βββββββββββββββββ Skip Analysis
β Crop Person β (Continue to
β Bounding Box β next frame)
βββββββββ¬ββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββ ββββββββββββββββββ
β FER Emotion β β Gender & Age β
β Recognition β β Classification β
β (Every 8th β β (Every 15th β
β frame) β β frame) β
βββββββββ¬ββββββββ ββββββββββ¬ββββββββ
β β
βΌ βΌ
βββββββββββββββββ ββββββββββββββββββ
β TFLite Body β β Demographics β
β Language β β β’ Gender β
β (Every 8th β β β’ Age Group β
β frame) β ββββββββββ¬ββββββββ
βββββββββ¬ββββββββ β
β β
βββββββββββββββ¬ββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β Multi-Modal Fusion β
β β’ Emotion Timeline β
β β’ Body Posture β
β β’ Demographics β
β β’ Processing Time β
βββββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β JSON Output β
β β’ Satisfaction Rate β
β β’ Processing Time β
β β’ Age β
β β’ Gender β
βββββββββββββββββββββββββ
| Model | Accuracy | Dataset | Classes |
|---|---|---|---|
| Gender Classification | 92.3% | UTKFace | 2 (Male/Female) |
| Age Classification | 77.1% | UTKFace | 9 age groups |
| Face Emotion (FER) | ~65% | FER2013 | 7 emotions |
| Body Language | Custom | Custom | 9 postures |
| Metric | CPU (i7) | GPU (RTX 3060) |
|---|---|---|
| FPS | 15-20 | 30-45 |
| Latency | 50-70ms | 20-35ms |
| Memory | ~2.5GB | ~3.5GB |
Optimization Techniques:
- Frame skipping (YOLO: 3x, FER: 8x, Demographics: 15x)
- Result caching between skipped frames
- ROI-focused processing (only analyze persons in counter area)
- Model inference batching
{
"id": 0,
"counterid": "C1",
"metrics[satisfaction_rate]": 0.85,
"metrics[processing_time]": 45,
"client_meta[age]": 25,
"client_meta[gender]": "female"
}| Field | Type | Range | Description |
|---|---|---|---|
id |
int | - | Session identifier |
counterid |
string | - | Counter identifier (C1, C2, etc.) |
satisfaction_rate |
float | 0.0-1.0 | Multi-modal satisfaction score |
processing_time |
int | seconds | Total time customer spent in ROI |
age |
int | years | Estimated age (from age group) |
gender |
string | male/female | Predicted gender |
# Clone repository
git clone https://github.com/l3b-sghar/Computer_vision.git
cd Computer_vision
# Install dependencies
pip install -r requirements.txtpip install opencv-python numpy ultralytics fer torch torchvision transformers tensorflow pillow requests scikit-learn matplotlib seaborncd full_pipeline
python main_simple.pyKey Controls:
- Press
QorESCto quit - Real-time video window shows all detections
- JSON output saved to
pipeline_output.json
Edit main_simple.py:
pipeline = IntegratedPipeline(
yolo_model_path="../examples/yolov8n.pt",
tflite_model_path="../models/body_language.tflite",
video_path="path/to/video.mp4", # or None for webcam
yolo_skip_frames=3,
fer_skip_frames=8,
gender_skip_frames=15,
age_skip_frames=15,
counter_id="C1"
)cd metrics
python generate_fake_metrics.pyResults saved in metrics/evaluation_results/.
Computer_vision/
βββ full_pipeline/
β βββ main_simple.py # Main integrated pipeline
β βββ pipeline_output.json # Results
βββ examples/ # Individual demos
βββ models/ # Model weights
βββ metrics/ # Evaluation scripts
βββ README.md # This file
MIT License
Repository: Computer_vision
Owner: l3b-sghar
Last Updated: November 16, 2025