An end-to-end real-time emotion tracker that captures and analyzes facial expressions using a powerful stack:
- OpenFace – for facial landmark detection and Action Unit (AU) extraction
- Kalman Filtering – to smooth noisy gaze signals and facial features
- Custom Feature Engineering – to extract blink rates, gaze focus, head pose, emotion frequency, and more
- Google Vertex AI – for summarizing and interpreting emotional states using a Large Language Model (LLM)
- Streams live facial tracking data using OpenFace
- Applies Kalman filtering to clean gaze and motion signals
- Detects emotions using AU-based logic (joy, anger, sadness, surprise, confusion, etc.)
- Engineers features in real time, including:
- Blink frequency
- Smile intensity
- Gaze deviation
- Emotional state distribution
- Periodically sends a consolidated summary to Vertex AI LLM to analyze user engagement and mood
{
"blink_freq": 0.27,
"smile_freq": 0.12,
"avg_head_tilt": 3.8,
"percent_away": 22.4,
"emotion_counts": {
"neutral": 19,
"joy": 6,
"confusion": 4
}
}🗣️ Prompt:
"Given the following user gaze and emotion features, analyze the user's cognitive and emotional state. Please describe the user's likely focus level, mood, and engagement."
Python 3.11OpenFace(AU detection)Kafka(streaming facial data)NumPy,deque,Kalman filters(signal smoothing)Vertex AI(LLM analysis and interpretation)
Feature extraction includes:
| Feature | Description |
|---|---|
blink_freq |
Blinks per second (based on AU45) |
smile_freq |
Smile activity from AU12/AU06 |
avg_head_tilt |
Pose_Rx average for attention tracking |
percent_away |
% of time gaze deviates from center |
emotion_counts |
Count of detected emotions in window |
-
Install OpenFace and make sure it's streaming facial data to Kafka
-
Install Python dependencies:
pip install numpy kafka-python
-
Run the consumer:
python kafka/consumer.py
-
Check
feature.txtfor real-time summaries and LLM prompts
- Emotion timeline charts
- Real-time dashboard UI (using WebSockets)
- Improved deep learning-based emotion detection
- Integration with video conferencing tools
MIT License. Use freely and contribute back!
Pull requests, ideas, and bug reports are welcome! If you’ve got a new way to engineer features or want to bring in another LLM provider—let’s collaborate!