| 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
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
20 struct EthnicityEstimation {
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
56 struct IAttributeEstimator : IRefCounted {
57
62 enum EstimationRequest {
63 estimateAge = 1 << 0,
64 estimateGender = 1 << 1,
65 estimateEthnicity = 1 << 2,
66 estimateAll = 0xffff
67 };
68
72 struct EstimationResult {
74 Optional<float> age;
76 Optional<float> gender;
78 Optional<float> genderScore;
80 Optional<EthnicityEstimation> ethnicity;
81 };
82
90 virtual Result<FSDKError> estimate(
91 const Image& warp,
92 const EstimationRequest request,
93 EstimationResult& out) const noexcept = 0;
94
105 virtual ResultValue<FSDKError, EstimationResult> estimate(
106 Span<const Image> warps,
107 const EstimationRequest request,
108 Span<EstimationResult> results) const noexcept = 0;
109
118 virtual Result<FSDKError>
119 validate(
120 Span<const Image> warps,
121 const EstimationRequest request,
122 Span<Result<FSDKError>> errors) const noexcept = 0;
123 };
124
128 using EstimationRequest = IAttributeEstimator::EstimationRequest;
129 using AttributeEstimationResult = IAttributeEstimator::EstimationResult;
130
131 /*
132 Implementation details.
133 */
134 EthnicityEstimation::Ethnicities
135 EthnicityEstimation::getPredominantEthnicity() const {
136 const float* arr = &this->africanAmerican;
137 return static_cast<EthnicityEstimation::Ethnicities>(
138 std::distance(arr, std::max_element(arr, arr+EthnicityEstimation::Count))
139 );
140 }
141
142 /*
143 Implementation details.
144 */
145 float
146 EthnicityEstimation::getEthnicityScore(
147 EthnicityEstimation::Ethnicities ethnicity
148 ) const {
149 return *(&this->africanAmerican + static_cast<uint32_t>(ethnicity));
150 }
151
152 /*
153 Implementation details.
154 */
155 inline IAttributeEstimator::EstimationRequest
156 operator|(
157 IAttributeEstimator::EstimationRequest first,
158 IAttributeEstimator::EstimationRequest second
159 ) {
160 return static_cast<IAttributeEstimator::EstimationRequest>(
161 static_cast<int>(first) | static_cast<int>(second)
162 );
163 }
164
165
166 } // namespace sdk
DECLARE_SMARTPTR
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
fsdk::IAttributeEstimator::validate
virtual Result< FSDKError > validate(Span< const Image > warps, const EstimationRequest request, 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
fsdk::IAttributeEstimator
Face image attribute estimator interface.
Definition: IAttributeEstimator.h:56
Types.h
Common data types and structures.
fsdk::IAttributeEstimator::estimate
virtual Result< FSDKError > estimate(const Image &warp, const EstimationRequest request, EstimationResult &out) const noexcept=0
Estimate unified attributes.
fsdk::IAttributeEstimator::EstimationResult::gender
Optional< float > gender
gender score if was requested (100% - male, 0% - female), empty otherwise
Definition: IAttributeEstimator.h:76
fsdk::IAttributeEstimator::estimateGender
Estimate gender.
Definition: IAttributeEstimator.h:64
fsdk::IAttributeEstimator::EstimationResult
Unified Attribute Estimator output structure.
Definition: IAttributeEstimator.h:72
fsdk::EthnicityEstimation::getPredominantEthnicity
Ethnicities getPredominantEthnicity() const
Returns ethnicity with greatest score.
Definition: IAttributeEstimator.h:135
IObject.h
Object system types and interfaces.
FSDKError.h
Common SDK error codes.
fsdk::IAttributeEstimator::EstimationResult::age
Optional< float > age
&lt; age estimation if was requested, empty otherwise
Definition: IAttributeEstimator.h:74
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:36
fsdk::EthnicityEstimation::getEthnicityScore
float getEthnicityScore(Ethnicities ethnicity) const
Returns score of required ethnicity.
Definition: IAttributeEstimator.h:146
fsdk::IAttributeEstimator::EstimationRequest
EstimationRequest
EstimationRequest lists all possible estimation attributes that AttributeEstimator is currently able ...
Definition: IAttributeEstimator.h:62
fsdk::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types...
Definition: ResultValue.h:21
fsdk::IAttributeEstimator::EstimationResult::genderScore
Optional< float > genderScore
ethnicity estimation if was requested, empty otherwise
Definition: IAttributeEstimator.h:78
fsdk::IAttributeEstimator::estimateAll
Make full estimation (all attributes)
Definition: IAttributeEstimator.h:66
fsdk::Image
Image.
Definition: Image.h:37
fsdk::EthnicityEstimation
Ethnicity estimation structure. Each estimation is given in normalized [0, 1] range.
Definition: IAttributeEstimator.h:20
fsdk::IAttributeEstimator::estimateEthnicity
Estimate Ethnicity.
Definition: IAttributeEstimator.h:65
fsdk::Span
Span. Not owning data view. It incapsulated pointer to the continuous array with one or more T objec...
Definition: Span.h:14
fsdk::IAttributeEstimator::estimateAge
Estimate age.
Definition: IAttributeEstimator.h:63