Skip to Content

Real-Time Emotion Detection Using OpenCV and Keras

2 April 2024 by
anurag parashar
| No comments yet

Project Overview

In this project, we developed a real-time emotion detection system using OpenCV and Keras. The system captures live video feed from a webcam, processes the frames to detect faces, and classifies the detected faces into one of seven emotions: Angry, Disgusted, Fearful, Happy, Neutral, Sad, and Surprised.

Technical Details

  • Face Detection: We used the Haar Cascade Classifier from OpenCV to detect faces in the video frames. The classifier is trained to recognize frontal faces and draw bounding boxes around them.
  • Emotion Classification: The detected faces are converted to grayscale and resized to 48x48 pixels. These preprocessed images are then fed into a Convolutional Neural Network (CNN) model built using Keras. The model predicts the emotion by outputting probabilities for each of the seven classes.
  • Model Architecture: The CNN model consists of multiple convolutional layers followed by max-pooling layers, dropout layers for regularization, and fully connected layers. The final layer uses a softmax activation function to output the probabilities for each emotion.
  • Real-Time Processing: The system continuously captures frames from the webcam, processes each frame to detect faces, and classifies the emotions in real-time. The results are displayed on the video feed with bounding boxes and emotion labels.

Achievements

  • High Accuracy: The model achieved high accuracy on the test dataset, demonstrating its effectiveness in real-time emotion detection.
  • Real-Time Performance: The system processes video frames in real-time, providing immediate feedback on detected emotions.
  • User-Friendly Interface: The implementation is straightforward, with clear instructions and code comments, making it easy for others to replicate and build upon.


Share this post
Archive
Sign in to leave a comment