This project has been made to learn the basics of the OpenCV library.
I used a dataset from kaggle (dataset) to build a neural network to recognize emotions. The dataset contained 48x48 grayscale images of faces and 7 labels. To simplify the task, I used only 3 labels - happiness, neutral, sadness. The neural network was trained and saved, the model is saved in this directory (model.h5)
The program captures the video from a camera and then processes each frame.
- face detection using face_cascade_classifier (available here)
1.1) before the classifier is applied, the image is converted to grayscale - for each face the program draws contours around the face
- for each face the program crops the image to obtain only the face
- on every cropped image of a face, the neural network predicts the most probable emotion
4.1) before the model gets the image, the cropped image needs to be converted to grayscale and resized to 48x48 pixels - having predicted the emotion, the program puts a label representing the emotion above the face
- the program can be stopped by clicking the ESC button
tensorflow==2.5.0
numpy==1.19.5
opencv-python==4.5.3.56
- include all 7 emotions from the dataset, not only 3
- improve the neural network, right now it sometimes struggles to recognize sadness
- tune the haarcascade classifier parameters, sometimes it considers something a face while it's not a face






