๐ง Project Summary:
This project implements a real-time facial emotion detection system using a Convolutional Neural Network (CNN) and OpenCV's Haar Cascade Classifier. It captures video from a webcam, detects faces in real time, and classifies them into one of seven emotional states: Anger, Disgust, Fear, Happy, Sad, Surprise, Neutral.
The model is trained on the FER2013 dataset and optimized for deployment in real-world scenarios. Designed with simplicity, efficiency, and educational clarity in mind, the system is ideal for student demos, educational projects, and real-time human-computer interaction research.
๐ฆ Files and Assets:
File Name Description
emotion_model.h5 Pre-trained CNN model trained on FER2013
main.py Real-time emotion detection script
haarcascades/haarcascade_frontalface_default.xml XML for face detection
README.md Project documentation and usage guide
๐ Model Details:
Architecture: Convolutional Neural Network (custom 4-layer)
Input Size: 64x64 grayscale
Output: Softmax prediction across 7 emotion classes
Dataset Used: FER-2013
๐ฅ๏ธ Tech Stack:
Programming Language: Python
Libraries: OpenCV, TensorFlow/Keras, NumPy
Model Format: .h5 (Keras Saved Model)
๐ป How it Works:
Captures video feed from the webcam.
Detects faces using Haarcascade XML.
Preprocesses the face image: grayscale, resized to 64x64, normalized.
Uses the CNN to predict emotion.
Displays bounding box and emotion label on-screen.
Optionally includes face-mapping or eye-tracking overlay text.
๐ Key Features:
๐ฅ Real-time Emotion Detection
๐ง CNN-based Accuracy
๐ก Face Mapping Text Overlay
๐งช Optional: Eye Detection Integration
๐ฅ๏ธ Lightweight and beginner-friendly code
๐ Press Q to exit webcam.
๐ ๏ธ Future Enhancements:
GUI Integration (Streamlit, Tkinter)
Add audio feedback or logging CSV of emotions
Integrate drowsiness or blink detection via eye tracking
Deploy on Raspberry Pi for edge AI applications
๐ Model Access (for Ready Tensor or similar platform):
Model Name: FacialEmotionDetector_CNN_Haarcascade
License: MIT
Version: 1.0
Author: Anshuman Tiwari (@anshuman-ai)
Email/Contact: [https://github.com/AnshumanTiwari2006/Face-Emotion-Detection/tree/main]
