Face Engine SDK  5.14.0
A face detection, recognition and tracking engine.
 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 
26  float anger;
27  float disgust;
28  float fear;
29  float happiness;
30  float sadness;
31  float surprise;
32  float neutral;
33 
34  enum Emotions {
35  Anger = 0,
36  Disgust,
37  Fear,
38  Happiness,
39  Sadness,
40  Surprise,
41  Neutral,
42  Count
43  };
44 
48  inline Emotions getPredominantEmotion() const;
49 
55  inline float getEmotionScore(Emotions emotion) const;
56  };
57 
75  virtual Result<FSDKError>
76  estimate(
77  const Image& warp,
78  EmotionsEstimation& estimation) const noexcept = 0;
79 
91  virtual Result<FSDKError>
92  estimate(
93  Span<const Image> warps,
94  Span<EmotionsEstimation> emotionEstimations) const noexcept = 0;
95 
106  virtual Result<FSDKError>
107  validate(
108  Span<const Image> warps,
109  Span<Result<FSDKError>> errors) const noexcept = 0;
110  };
111 
112  /*
113  Implementation details.
114  */
115  EmotionsEstimation::Emotions
117  const float* arr = &this->anger;
118  return static_cast<EmotionsEstimation::Emotions>(
119  std::distance(arr, std::max_element(arr, arr+EmotionsEstimation::Count))
120  );
121  }
122 
123  /*
124  Implementation details.
125  */
126  float EmotionsEstimation::getEmotionScore(Emotions emotion) const {
127  return *(&this->anger + static_cast<uint32_t>(emotion));
128  }
130 } // namespace fsdk
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
float surprise
0(not surprised)..1(surprised);
Definition: IEmotionsEstimator.h:31
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.
A structure that encapsulates an action result enumeration.
Definition: Result.h:29
Common data types and structures.
Object system types and interfaces.
float getEmotionScore(Emotions emotion) const
Returns score of required emotion.
Definition: IEmotionsEstimator.h:126
Common SDK error codes.
virtual Result< FSDKError > estimate(const Image &warp, EmotionsEstimation &estimation) const noexcept=0
Estimate the attributes.
Base strong reference counted object interface.
Definition: IRefCounted.h:36
Emotions estimator interface.
Definition: IEmotionsEstimator.h:65
float anger
0(not angry)..1(angry);
Definition: IEmotionsEstimator.h:26
float sadness
0(not sad)..1(sad);
Definition: IEmotionsEstimator.h:30
float neutral
0(not neutral)..1(neutral).
Definition: IEmotionsEstimator.h:32
Image.
Definition: Image.h:39
float happiness
0(not happy)..1(happy);
Definition: IEmotionsEstimator.h:29
Emotions estimation structure. Each estimation is given in normalized [0, 1] range.
Definition: IEmotionsEstimator.h:25
float fear
0(no fear)..1(fear);
Definition: IEmotionsEstimator.h:28
float disgust
0(not disgusted)..1(disgusted);
Definition: IEmotionsEstimator.h:27
Span. Not owning data view. It incapsulated pointer to the continuous array with one or more T objec...
Definition: Span.h:14
Emotions getPredominantEmotion() const
Returns emotion with greatest score.
Definition: IEmotionsEstimator.h:116