5 #include <fsdk/Optional.h>
12 #ifndef DOXYGEN_SHOULD_SKIP_THIS
24 struct EthnicityEstimation {
25 float africanAmerican;
42 inline Ethnicities getPredominantEthnicity()
const;
49 inline float getEthnicityScore(Ethnicities ethnicity)
const;
64 struct IAttributeEstimator : IRefCounted {
69 enum EstimationRequest {
71 estimateGender = 1 << 1,
72 estimateEthnicity = 1 << 2,
79 struct EstimationResult {
83 Optional<float> gender;
85 Optional<float> genderScore;
87 Optional<EthnicityEstimation> ethnicity;
100 virtual Result<FSDKError> estimate(
102 const EstimationRequest request,
103 EstimationResult& out)
const noexcept = 0;
117 virtual ResultValue<FSDKError, EstimationResult> estimate(
118 Span<const Image> warps,
119 const EstimationRequest request,
120 Span<EstimationResult> results)
const noexcept = 0;
134 virtual Result<FSDKError>
136 Span<const Image> warps,
137 const EstimationRequest request,
138 Span<Result<FSDKError>> errors) const noexcept = 0;
144 using EstimationRequest = IAttributeEstimator::EstimationRequest;
145 using AttributeEstimationResult = IAttributeEstimator::EstimationResult;
150 EthnicityEstimation::Ethnicities
151 EthnicityEstimation::getPredominantEthnicity()
const {
152 const float* arr = &this->africanAmerican;
153 return static_cast<EthnicityEstimation::Ethnicities
>(
154 std::distance(arr, std::max_element(arr, arr+EthnicityEstimation::Count))
162 EthnicityEstimation::getEthnicityScore(
163 EthnicityEstimation::Ethnicities ethnicity
165 return *(&this->africanAmerican +
static_cast<uint32_t
>(ethnicity));
171 inline IAttributeEstimator::EstimationRequest
173 IAttributeEstimator::EstimationRequest first,
174 IAttributeEstimator::EstimationRequest second
176 return static_cast<IAttributeEstimator::EstimationRequest
>(
177 static_cast<int>(first) | static_cast<int>(second)
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:59
Common data types and structures.
Object system types and interfaces.