7#ifndef FACIAL_ANALYSIS_H
8#define FACIAL_ANALYSIS_H
10#include <opencv2/opencv.hpp>
13#include <xtensor/containers/xarray.hpp>
136 static std::unique_ptr<EmotiEffLibRecognizer>
137 createInstance(
const std::string& backend,
const std::string& fullPipelineModelPath);
183 virtual xt::xarray<float>
extractFeatures(
const std::vector<cv::Mat>& faceImgs);
193 bool logits =
true) = 0;
268 virtual xt::xarray<float>
preprocess(
const cv::Mat& img) = 0;
284 static void checkBackend(
const std::string& backend);
Base class for emotion and engagement recognition.
virtual void initRecognizer(const std::string &modelPath)
Initializes the internal state of recognizer based on a modelPath.
EmotiEffLibRes processEngagementScores(const xt::xarray< float > &scores)
Common method to processes engagement scores and generate classification results.
bool isMtl_
Whether the model is multi-task learning (MTL).
xt::xarray< float > engagementFeaturesPreprocess(const xt::xarray< float > features)
Preprocesses engagement features.
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.
int imgSize_
Input image size.
int engagementClassifierIdx_
Index of the engagement classifier model in the array with models.
virtual EmotiEffLibRes classifyEngagement(const xt::xarray< float > &features)=0
Classifies engagement based on extracted features.
int featureExtractorIdx_
Index of the model for features extraction in the array with models.
int classifierIdx_
Index of the classifier model in the array with models.
int fullPipelineModelIdx_
Index of the full pipeline model in the array with models.
std::string getEmotionClassById(int idx)
Gets the emotion class name by index.
const int engagementSlidingWindowSize_
Sliding window size for engagement prediction.
virtual xt::xarray< float > preprocess(const cv::Mat &img)=0
Preprocesses an image for feature extraction.
std::string getEngagementClassById(int idx)
Gets the engagement class name by index.
virtual void configParser(const EmotiEffLibConfig &config)=0
Parses the configuration to initialize the recognizer.
std::vector< std::string > idxToEngagementClass_
Engagement class names.
virtual ~EmotiEffLibRecognizer()=default
std::vector< std::string > idxToEmotionClass_
Emotion class names.
EmotiEffLibRes processEmotionScores(const xt::xarray< float > &scores, bool logits)
Common method to processes emotion scores and generate classification results.
std::string modelName_
Name of the model.
virtual EmotiEffLibRes classifyEmotions(const xt::xarray< float > &features, bool logits=true)=0
Classifies emotions based on extracted features.
virtual EmotiEffLibRes predictEmotions(const cv::Mat &faceImg, bool logits=true)=0
Predicts emotions for a single face image.
virtual EmotiEffLibRes predictEngagement(const std::vector< cv::Mat > &faceImgs)=0
Predicts engagement for a sequence of face images.
virtual xt::xarray< float > extractFeatures(const cv::Mat &faceImg)=0
Extracts features from a single face image.
std::vector< std::string > getAvailableBackends()
Retrieves the list of available inference backends.
std::vector< std::string > getSupportedModels(const std::string &backendName)
Retrieves the list of supported emotion or engagement recognition models.
Configuration structure for the EmotiEffLibRecognizer.
std::string classifierPath
Path to the emotion classifier model file.
std::string backend
The inference backend to use.
std::string featureExtractorPath
Path to the feature extractor model file.
std::string fullPipelineEmotionModelPath
Path to the model with full emotion recognition pipeline.
std::string modelName
The name of the selected model.
std::string engagementClassifierPath
Path to the engagement classifier model file.
Structure to store the results of EmotiEffLib.
xt::xarray< float > scores
The confidence scores for each input frame.
std::vector< std::string > labels
The predicted emotion/engagement labels.