A webcam app that tries to detect pain from facial expressions using computer vision. I built this to learn about FACS-based pain detection and real-time video processing.
Uses your webcam to track facial muscle movements and estimate whether someone might be in pain. Based on the Facial Action Coding System (FACS) — looking for specific action units like brow furrowing, eye squinting, and nose wrinkling that consistently appear in pain expressions across clinical research.
Not a medical tool. Student project.
pip install -r requirements.txt
python -m streamlit run app.py --server.port 8502Go to http://localhost:8502
- Click "Start Webcam"
- Let it detect your face
- Click "Set Baseline" with a neutral expression
- Make different expressions to see the detection respond
src/
detection/ face detection and feature extraction
models/ CNN model (optional, rule-based works for testing)
visualization/ drawing overlays on the video feed
app.py main Streamlit app
train_model.py train the CNN yourself if you want
- Python 3.8+
- Webcam
- Packages in requirements.txt
Lighting affects accuracy significantly. Works differently across people. Not validated on clinical populations. The rule-based approach is good enough for exploring how the system responds — the CNN model is optional and needs its own training data to be useful.
Youssof Sallam. Microexpression Pain Detector (2025). GitHub. https://github.com/youssof20/microexpression-pain-detector