For more info
Solution Video Link
You are tasked with building a personalized compliment generator based on facial analysis. The feature should:
- Detect the user’s face in an image or live feed.
- Analyze their facial expression (e.g., smile, neutral).
- Generate and display a compliment (e.g., “Your smile is glowing today!”) based on the detected expression.
The program captures your camera feed and the library 'fer' is used to detect emotions. The random module then picks a compliment according to the emotion and compliments the user on the video output.
- Display a compliment tailored to the detected expression.

- Compliment doesn't cover the face.
- Compliment is spoken from PC speaker.

- TFT LCD Display is connected to Raspberry Pi with Jumper Wires and compliment is shown in it.
Libraries
OpenCV
FER Library
pyttsx3
Tools
ChatGPT
StackOverflow
ModuleNotFoundError: No module named 'moviepy.editor'
reference
Fixed this by installing specific version of moviepy
Rapid change of compliment random compliments, even without change of emotion
Fixed this by having a record of previous emotion (prev_emotion) and change compliment only when current emotion (curr_emotion) is not same as the previous one.
Compliment's length was longer than the width of screen
Fixed this by splitting the lines of the compliment and putting text one line at a time.
Rapid change in compliments
This was faced because the model is considering the current frame, without taking previousframe into account, which is causing rapid changes in guessed emotions. To fix this, I have eased out the switch so that a new compliment is picked, only when there is more than 20% change in the emotion.
Get dimensions taken by a word on the camera frame
A static method named getTextSize exist in cv2 which gives the size that text takes on screen.
No camera available to connect to Raspberry Pi
Use DroidCam Client on mobile to host the video feed on LAN and access it from VLC in Pi.
Not sufficient storage in SD Card of Raspberry Pi
Making a bootable pendrive (64GB).
Raspberry Pi TTY
Prepare pendrive for Raspberry Pi
Clone the Repo (Ensure Python is >=3.10.6)
git clone https://github.com/hardikjumnani/facial-expression-analyser
git checkout raspberry-pi
python -m venv .venv
python3 -m venv .venv
source .venv/Scripts/activate
source .venv/bin/activate
pip install -r requirements.txt
pip3 install -r requirements.txt
python main.py
python3 main_raspberry_pi.py
