|
EmotiEffCppLib
Cpp implementation of Emotion Efficient Library
|
Base class for emotion and engagement recognition. More...
#include <facial_analysis.h>


Public Member Functions | |
| virtual | ~EmotiEffLibRecognizer ()=default |
| virtual EmotiEffLibRes | classifyEmotions (const xt::xarray< float > &features, bool logits=true)=0 |
| Classifies emotions based on extracted features. | |
| virtual EmotiEffLibRes | classifyEngagement (const xt::xarray< float > &features)=0 |
| Classifies engagement based on extracted features. | |
| virtual xt::xarray< float > | extractFeatures (const cv::Mat &faceImg)=0 |
| Extracts features from a single face image. | |
| virtual xt::xarray< float > | extractFeatures (const std::vector< cv::Mat > &faceImgs) |
| Extracts features from a sequence of face images. | |
| std::string | getEmotionClassById (int idx) |
| Gets the emotion class name by index. | |
| std::string | getEngagementClassById (int idx) |
| Gets the engagement class name by index. | |
| virtual EmotiEffLibRes | predictEmotions (const cv::Mat &faceImg, bool logits=true)=0 |
| Predicts emotions for a single face image. | |
| virtual EmotiEffLibRes | predictEmotions (const std::vector< cv::Mat > &faceImgs, bool logits=true) |
| Predicts emotions for a sequence of face images. | |
| virtual EmotiEffLibRes | predictEngagement (const std::vector< cv::Mat > &faceImgs)=0 |
| Predicts engagement for a sequence of face images. | |
Static Public Member Functions | |
| static std::unique_ptr< EmotiEffLibRecognizer > | createInstance (const EmotiEffLibConfig &config) |
| Creates an instance of the EmotiEffLibRecognizer with the specified configuration. | |
| static std::unique_ptr< EmotiEffLibRecognizer > | createInstance (const std::string &backend, const std::string &fullPipelineModelPath) |
| Creates an instance of the EmotiEffLibRecognizer with the specified backend and model path. | |
Protected Member Functions | |
| virtual void | configParser (const EmotiEffLibConfig &config)=0 |
| Parses the configuration to initialize the recognizer. | |
| xt::xarray< float > | engagementFeaturesPreprocess (const xt::xarray< float > features) |
| Preprocesses engagement features. | |
| virtual void | initRecognizer (const std::string &modelPath) |
| Initializes the internal state of recognizer based on a modelPath. | |
| virtual xt::xarray< float > | preprocess (const cv::Mat &img)=0 |
| Preprocesses an image for feature extraction. | |
| EmotiEffLibRes | processEmotionScores (const xt::xarray< float > &scores, bool logits) |
| Common method to processes emotion scores and generate classification results. | |
| EmotiEffLibRes | processEngagementScores (const xt::xarray< float > &scores) |
| Common method to processes engagement scores and generate classification results. | |
Protected Attributes | |
| int | classifierIdx_ = -1 |
| Index of the classifier model in the array with models. | |
| int | engagementClassifierIdx_ = -1 |
| Index of the engagement classifier model in the array with models. | |
| const int | engagementSlidingWindowSize_ = 128 |
| Sliding window size for engagement prediction. | |
| int | featureExtractorIdx_ = -1 |
| Index of the model for features extraction in the array with models. | |
| int | fullPipelineModelIdx_ = -1 |
| Index of the full pipeline model in the array with models. | |
| std::vector< std::string > | idxToEmotionClass_ |
| Emotion class names. | |
| std::vector< std::string > | idxToEngagementClass_ = {"Distracted", "Engaged"} |
| Engagement class names. | |
| int | imgSize_ |
| Input image size. | |
| bool | isMtl_ |
| Whether the model is multi-task learning (MTL). | |
| std::string | modelName_ = "" |
| Name of the model. | |
Base class for emotion and engagement recognition.
This class provides the interface for emotion and engagement recognition using different backends. It supports feature extraction, emotion classification, and engagement prediction.
Definition at line 121 of file facial_analysis.h.
|
virtualdefault |
|
pure virtual |
Classifies emotions based on extracted features.
| features | The extracted features. |
| logits | Whether to return raw logits or apply softmax. |
Implemented in EmotiEffLib::EmotiEffLibRecognizerOnnx, and EmotiEffLib::EmotiEffLibRecognizerTorch.
|
pure virtual |
Classifies engagement based on extracted features.
| features | The extracted features. |
Implemented in EmotiEffLib::EmotiEffLibRecognizerOnnx, and EmotiEffLib::EmotiEffLibRecognizerTorch.
|
protectedpure virtual |
Parses the configuration to initialize the recognizer.
| config | The configuration structure. |
|
static |
Creates an instance of the EmotiEffLibRecognizer with the specified configuration.
| config | The configuration structure containing backend and model paths. |
Definition at line 59 of file facial_analysis.cpp.
|
static |
Creates an instance of the EmotiEffLibRecognizer with the specified backend and model path.
| backend | The inference backend to use ("torch" or "onnx"). |
| fullPipelineModelPath | Path to the full pipeline model file. |
Definition at line 45 of file facial_analysis.cpp.
|
protected |
Preprocesses engagement features.
| features | The extracted features. |
Definition at line 185 of file facial_analysis.cpp.
|
pure virtual |
Extracts features from a single face image.
| faceImg | The input face image. |
Implemented in EmotiEffLib::EmotiEffLibRecognizerOnnx, and EmotiEffLib::EmotiEffLibRecognizerTorch.
|
virtual |
Extracts features from a sequence of face images.
| faceImgs | A list of input face images. |
Definition at line 71 of file facial_analysis.cpp.
|
inline |
Gets the emotion class name by index.
| idx | The index of the emotion class. |
Definition at line 156 of file facial_analysis.h.
|
inline |
Gets the engagement class name by index.
| idx | The index of the engagement class. |
Definition at line 164 of file facial_analysis.h.
|
protectedvirtual |
Initializes the internal state of recognizer based on a modelPath.
| modelPath | Path to the model file. |
Definition at line 104 of file facial_analysis.cpp.
|
pure virtual |
Predicts emotions for a single face image.
| faceImg | The input face image. |
| logits | Whether to return raw logits or apply softmax. |
Implemented in EmotiEffLib::EmotiEffLibRecognizerOnnx, and EmotiEffLib::EmotiEffLibRecognizerTorch.
|
virtual |
Predicts emotions for a sequence of face images.
| faceImgs | A list of input face images. |
| logits | Whether to return raw logits or apply softmax. |
Definition at line 86 of file facial_analysis.cpp.
|
pure virtual |
Predicts engagement for a sequence of face images.
| faceImgs | A list of input face images. |
Implemented in EmotiEffLib::EmotiEffLibRecognizerOnnx, and EmotiEffLib::EmotiEffLibRecognizerTorch.
|
protectedpure virtual |
Preprocesses an image for feature extraction.
| img | The input image. |
|
protected |
Common method to processes emotion scores and generate classification results.
| scores | The raw emotion scores. |
| logits | Whether to return raw logits or apply softmax. |
Definition at line 133 of file facial_analysis.cpp.
|
protected |
Common method to processes engagement scores and generate classification results.
| scores | The raw engagement scores. |
Definition at line 171 of file facial_analysis.cpp.
|
protected |
Index of the classifier model in the array with models.
Definition at line 294 of file facial_analysis.h.
|
protected |
Index of the engagement classifier model in the array with models.
Definition at line 296 of file facial_analysis.h.
|
protected |
Sliding window size for engagement prediction.
Definition at line 298 of file facial_analysis.h.
|
protected |
Index of the model for features extraction in the array with models.
Definition at line 292 of file facial_analysis.h.
|
protected |
Index of the full pipeline model in the array with models.
Definition at line 290 of file facial_analysis.h.
|
protected |
Emotion class names.
Definition at line 302 of file facial_analysis.h.
|
protected |
Engagement class names.
Definition at line 300 of file facial_analysis.h.
|
protected |
Input image size.
Definition at line 306 of file facial_analysis.h.
|
protected |
Whether the model is multi-task learning (MTL).
Definition at line 304 of file facial_analysis.h.
|
protected |
Name of the model.
Definition at line 288 of file facial_analysis.h.