This project is a Python-based application that captures video from the webcam and detects facial emotions using a pre-trained model from the fer
package. Detected emotions are displayed on the video feed with bounding boxes and confidence scores.
- Real-time facial emotion detection using a webcam.
- Displays bounding boxes around detected faces with the dominant emotion and confidence score.
- Python 3.7+
- OpenCV
fer
package (Facial Expression Recognition)
-
Clone the repository:
git clone https://github.com/hija-happy/facial-emotion-detection-using-opencv.git cd facial-emotion-detection-using-opencv
-
Create a virtual environment (optional but recommended):
python -m venv env source env/bin/activate # On Windows use `env\Scripts\activate`
-
Install the required libraries:
pip install opencv-python-headless numpy fer
- Ensure your webcam is connected and working.
- Run the application:
python emotion_detection.py
- The application will open a video feed window from your webcam.
- It will detect faces in real-time and draw bounding boxes around them.
- The detected emotion and its confidence score will be displayed above each face.
- Press the 'q' key to exit the application.
- Ensure that your webcam is properly connected and configured.
- The application uses the
fer
package for emotion detection and OpenCV for video capture and processing. - TensorFlow is a dependency of the
fer
package, even though it is not directly used in this application. It is required for the emotion detection functionality.