Face Engine SDK  4.6.0
A face detection, recognition and tracking engine.
IAttributeEstimator.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(IAttributeEstimator);
14 #endif
15 
21  float africanAmerican;
22  float indian;
23  float asian;
24  float caucasian;
25 
26  enum Ethnicities {
27  AfricanAmerican = 0,
28  Indian,
29  Asian,
30  Caucasian,
31  Count
32  };
33 
37  inline Ethnicities getPredominantEthnicity() const;
38 
43  inline float getEthnicityScore(Ethnicities ethnicity) const;
44  };
45 
57 
63  estimateAge = 1 << 0,
64  estimateGender = 1 << 1,
65  estimateEthnicity = 1 << 2,
66  estimateAll = 0xffff
67  };
68 
81  };
82 
91  const Image& warp,
93  IAttributeEstimator::EstimationResult& out) const noexcept = 0;
94 
106  const Span<const Image> warps,
108  Span<IAttributeEstimator::EstimationResult> results) const noexcept = 0;
109  };
110 
116 
117  /*
118  Implementation details.
119  */
120  EthnicityEstimation::Ethnicities
122  const float* arr = &this->africanAmerican;
123  return static_cast<EthnicityEstimation::Ethnicities>(
124  std::distance(arr, std::max_element(arr, arr+EthnicityEstimation::Count))
125  );
126  }
127 
128  /*
129  Implementation details.
130  */
131  float
133  EthnicityEstimation::Ethnicities ethnicity
134  ) const {
135  return *(&this->africanAmerican + static_cast<uint32_t>(ethnicity));
136  }
137 
138  /*
139  Implementation details.
140  */
142  operator|(
145  ) {
146  return static_cast<IAttributeEstimator::EstimationRequest>(
147  static_cast<int>(first) | static_cast<int>(second)
148  );
149  }
150 
151 
152 } // namespace sdk
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
SDK namespace.
Definition: IAGSEstimator.h:8
virtual Result< FSDKError > estimate(const Image &warp, const IAttributeEstimator::EstimationRequest request, IAttributeEstimator::EstimationResult &out) const noexcept=0
Estimate unified attributes.
Face image attribute estimator interface.
Definition: IAttributeEstimator.h:56
Common data types and structures.
Optional< float > gender
gender score if was requested (100% - male, 0% - female), empty otherwise
Definition: IAttributeEstimator.h:76
Estimate gender.
Definition: IAttributeEstimator.h:64
Unified Attribute Estimator output structure.
Definition: IAttributeEstimator.h:72
Object system types and interfaces.
Common SDK error codes.
Optional< float > age
< age estimation if was requested, empty otherwise
Definition: IAttributeEstimator.h:74
Base strong reference counted object interface.
Definition: IRefCounted.h:36
Ethnicities getPredominantEthnicity() const
Returns ethnicity with greatest score.
Definition: IAttributeEstimator.h:121
EstimationRequest
EstimationRequest lists all possible estimation attributes that AttributeEstimator is currently able ...
Definition: IAttributeEstimator.h:62
float getEthnicityScore(Ethnicities ethnicity) const
Returns score of required ethnicity.
Definition: IAttributeEstimator.h:132
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:21
Optional< float > genderScore
ethnicity estimation if was requested, empty otherwise
Definition: IAttributeEstimator.h:78
Make full estimation (all attributes)
Definition: IAttributeEstimator.h:66
Image.
Definition: Image.h:37
Ethnicity estimation structure. Each estimation is given in normalized [0, 1] range.
Definition: IAttributeEstimator.h:20
Estimate Ethnicity.
Definition: IAttributeEstimator.h:65
Span. Not owning data view. It incapsulated pointer to the continuous array with one or more T objec...
Definition: Span.h:13
Estimate age.
Definition: IAttributeEstimator.h:63