Project Code Overview
The Emotion Recognition Engine is a software library designed to detect faces and assign emotion labels. This tool primarily utilizes OpenCV and custom neural network components to detect faces, map facial landmarks, and classify emotions.
Key Components
Core Classes
- EmotionRecognitionEngine: The main engine that detects faces and assigns emotion labels.
- EngineBase: The main engine class for processing images and applying visual features.
- Detection: A structure to represent the details of a detected object, including confidence, class ID, name, and bounding rectangle.
- NeuralBase: A base class for implementing neural networks, providing functionalities to load, configure, and run inference.
- NeuralClassifierBase: A base class for neural network classifiers.
Face Detection and Emotion Classification
FaceDetectorYunet: Utilizes OpenCV's FaceDetectorYN model with DNN support for face detection. It detects faces and provides bounding boxes and landmarks.
EmotionClassifier: A neural network-based classifier for estimating facial emotions.
Facial Landmark and Visualization
- FaceMesh: Builds on the neural network framework to identify and process facial landmarks, enabling the creation of a face mesh.
- FaceDrawer: Handles the drawing of triangulations on faces based on facial points.
- LandmarkFlowFilter: Implements a filter to track landmarks in a sequence of images using optical flow techniques.
Mathematics and Image Utilities
CvUtils: Contains various utilities for image and math operations, such as resizing rectangles, histogram equalization, and calculating angles or transformations between points using OpenCV.
Function Highlights
- Engine Initialization:
EmotionRecognitionEngine::init(resourcePath)
initializes the engine with the required assets and configurations.
- Image Processing:
EmotionRecognitionEngine::process(input, output)
processes a frame to analyze and overlay emotion information.
- Watermarking:
EngineBase::addSigno(image)
adds a copyright watermark to an image.
- Face Detection:
FaceDetectorYunet::process(frame)
detects faces in a given frame and returns a list of Detection objects.
- Face Mesh Detection:
FaceMesh::process(frame, detections)
processes an image frame to detect face mesh structures.
- Drawing:
FaceDrawer::draw(image, facialPoints)
draws a triangular mesh over the provided facial points on an image.
File and Dependency Structure
The project files are organized in the C:/Projects/Engine/AntalEngine/Engine
directory. Key files include:
- EmotionRecognitionEngine.h: Defines the main
EmotionRecognitionEngine
class.
- EngineBase.h: Defines the base
EngineBase
class.
- EmotionClassifier.h: Contains the emotion classification capabilities.
- FaceDetectorYunet.h: Contains face detection capabilities.
- FaceMesh.h: Implements face mesh detection.
- FaceDrawer.h: Implements drawing on the face.
- LandmarkFlowFilter.h: Defines the filter for tracking facial landmarks.
- NeuralBase.h: Contains core neural network functionalities and configurations.
- Detection.h: Contains the Detection struct for object detection data.
- CvUtils.h: Provides image processing utilities.
This modular structure allows for the use of each component independently or as part of a larger, facial recognition-based application.