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

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
22 float anger;
23 float disgust;
24 float fear;
25 float happiness;
26 float sadness;
27 float surprise;
28 float neutral;
29
30 enum Emotions {
31 Anger = 0,
32 Disgust,
33 Fear,
34 Happiness,
35 Sadness,
36 Surprise,
37 Neutral,
38 Count
39 };
40
44 inline Emotions getPredominantEmotion() const;
45
50 inline float getEmotionScore(Emotions emotion) const;
51 };
52
60 struct IEmotionsEstimator : IRefCounted {
68 virtual Result<FSDKError>
69 estimate(
70 const Image& warp,
71 EmotionsEstimation& estimation) const noexcept = 0;
72 };
73
74 /*
75 Implementation details.
76 */
77 EmotionsEstimation::Emotions
78 EmotionsEstimation::getPredominantEmotion() const {
79 const float* arr = &this->anger;
80 return static_cast<EmotionsEstimation::Emotions>(
81 std::distance(arr, std::max_element(arr, arr+EmotionsEstimation::Count))
82 );
83 }
84
85 /*
86 Implementation details.
87 */
88 float EmotionsEstimation::getEmotionScore(Emotions emotion) const {
89 return *(&this->anger + static_cast<uint32_t>(emotion));
90 }
91
92 } // namespace fsdk
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
fsdk::EmotionsEstimation::surprise
float surprise
0(not surprised)..1(surprised);
Definition: IEmotionsEstimator.h:27
fsdk::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:29
Types.h
Common data types and structures.
fsdk::EmotionsEstimation::getPredominantEmotion
Emotions getPredominantEmotion() const
Returns emotion with greatest score.
Definition: IEmotionsEstimator.h:78
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::getEmotionScore
float getEmotionScore(Emotions emotion) const
Returns score of required emotion.
Definition: IEmotionsEstimator.h:88
fsdk::EmotionsEstimation::anger
float anger
0(not angry)..1(angry);
Definition: IEmotionsEstimator.h:22
fsdk::EmotionsEstimation::sadness
float sadness
0(not sad)..1(sad);
Definition: IEmotionsEstimator.h:26
fsdk::EmotionsEstimation::neutral
float neutral
0(not neutral)..1(neutral).
Definition: IEmotionsEstimator.h:28
fsdk::Image
Image.
Definition: Image.h:37
fsdk::EmotionsEstimation::happiness
float happiness
0(not happy)..1(happy);
Definition: IEmotionsEstimator.h:25
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:24
fsdk::EmotionsEstimation::disgust
float disgust
0(not disgusted)..1(disgusted);
Definition: IEmotionsEstimator.h:23