| Face Engine SDK 5.12.0 A face detection, recognition and tracking engine.

IEmotionsEstimator.h
1 #pragma once
2
3 #include <fsdk/IObject.h>
4 #include <fsdk/FSDKError.h>
5 #include <fsdk/Optional.h>
6 #include <fsdk/Types.h>
7
8 #include <algorithm>
9
10 namespace fsdk {
11
12 #ifndef DOXYGEN_SHOULD_SKIP_THIS
13 DECLARE_SMARTPTR(IEmotionsEstimator);
14 #endif
15
20 struct EmotionsEstimation {
21 float anger;
22 float disgust;
23 float fear;
24 float happiness;
25 float sadness;
26 float surprise;
27 float neutral;
28
29 enum Emotions {
30 Anger = 0,
31 Disgust,
32 Fear,
33 Happiness,
34 Sadness,
35 Surprise,
36 Neutral,
37 Count
38 };
39
43 inline Emotions getPredominantEmotion() const;
44
50 inline float getEmotionScore(Emotions emotion) const;
51 };
52
60 struct IEmotionsEstimator : IRefCounted {
70 virtual Result<FSDKError>
71 estimate(
72 const Image& warp,
73 EmotionsEstimation& estimation) const noexcept = 0;
74
86 virtual Result<FSDKError>
87 estimate(
88 Span<const Image> warps,
89 Span<EmotionsEstimation> emotionEstimations) const noexcept = 0;
90
101 virtual Result<FSDKError>
102 validate(
103 Span<const Image> warps,
104 Span<Result<FSDKError>> errors) const noexcept = 0;
105 };
106
107 /*
108 Implementation details.
109 */
110 EmotionsEstimation::Emotions
111 EmotionsEstimation::getPredominantEmotion() const {
112 const float* arr = &this->anger;
113 return static_cast<EmotionsEstimation::Emotions>(
114 std::distance(arr, std::max_element(arr, arr+EmotionsEstimation::Count))
115 );
116 }
117
118 /*
119 Implementation details.
120 */
121 float EmotionsEstimation::getEmotionScore(Emotions emotion) const {
122 return *(&this->anger + static_cast<uint32_t>(emotion));
123 }
124
125 } // namespace fsdk
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::EmotionsEstimation::surprise
float surprise
0(not surprised)..1(surprised);
Definition: IEmotionsEstimator.h:26
fsdk::EmotionsEstimation::getPredominantEmotion
Emotions getPredominantEmotion() const
Returns emotion with greatest score.
Definition: IEmotionsEstimator.h:111
fsdk::IEmotionsEstimator::validate
virtual Result< FSDKError > validate(Span< const Image > warps, Span< Result< FSDKError >> errors) const noexcept=0
Validate input of multiple frames in a single function call.
fsdk::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:29
Types.h
Common data types and structures.
IObject.h
Object system types and interfaces.
FSDKError.h
Common SDK error codes.
fsdk::IEmotionsEstimator::estimate
virtual Result< FSDKError > estimate(const Image &warp, EmotionsEstimation &estimation) const noexcept=0
Estimate the attributes.
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:36
fsdk::IEmotionsEstimator
Emotions estimator interface.
Definition: IEmotionsEstimator.h:60
fsdk::EmotionsEstimation::anger
float anger
0(not angry)..1(angry);
Definition: IEmotionsEstimator.h:21
fsdk::EmotionsEstimation::sadness
float sadness
0(not sad)..1(sad);
Definition: IEmotionsEstimator.h:25
fsdk::EmotionsEstimation::neutral
float neutral
0(not neutral)..1(neutral).
Definition: IEmotionsEstimator.h:27
fsdk::EmotionsEstimation::getEmotionScore
float getEmotionScore(Emotions emotion) const
Returns score of required emotion.
Definition: IEmotionsEstimator.h:121
fsdk::Image
Image.
Definition: Image.h:38
fsdk::EmotionsEstimation::happiness
float happiness
0(not happy)..1(happy);
Definition: IEmotionsEstimator.h:24
fsdk::EmotionsEstimation
Emotions estimation structure. Each estimation is given in normalized [0, 1] range.
Definition: IEmotionsEstimator.h:20
fsdk::EmotionsEstimation::fear
float fear
0(no fear)..1(fear);
Definition: IEmotionsEstimator.h:23
fsdk::EmotionsEstimation::disgust
float disgust
0(not disgusted)..1(disgusted);
Definition: IEmotionsEstimator.h:22
fsdk::Span
Span. Not owning data view. It incapsulated pointer to the continuous array with one or more T objec...
Definition: Span.h:14