5 #include <fsdk/Optional.h>
12 #ifndef DOXYGEN_SHOULD_SKIP_THIS
19 struct EthnicityEstimation {
20 float africanAmerican;
37 inline Ethnicities getPredominantEthnicity()
const;
44 inline float getEthnicityScore(Ethnicities ethnicity)
const;
59 struct IAttributeEstimator : IRefCounted {
64 enum EstimationRequest {
66 estimateGender = 1 << 1,
67 estimateEthnicity = 1 << 2,
74 struct EstimationResult {
78 Optional<float> gender;
80 Optional<float> genderScore;
82 Optional<EthnicityEstimation> ethnicity;
95 virtual Result<FSDKError> estimate(
97 const EstimationRequest request,
98 EstimationResult& out)
const noexcept = 0;
112 virtual ResultValue<FSDKError, EstimationResult> estimate(
113 Span<const Image> warps,
114 const EstimationRequest request,
115 Span<EstimationResult> results)
const noexcept = 0;
129 virtual Result<FSDKError>
131 Span<const Image> warps,
132 const EstimationRequest request,
133 Span<Result<FSDKError>> errors) const noexcept = 0;
139 using EstimationRequest = IAttributeEstimator::EstimationRequest;
140 using AttributeEstimationResult = IAttributeEstimator::EstimationResult;
145 EthnicityEstimation::Ethnicities
146 EthnicityEstimation::getPredominantEthnicity()
const {
147 const float* arr = &this->africanAmerican;
148 return static_cast<EthnicityEstimation::Ethnicities
>(
149 std::distance(arr, std::max_element(arr, arr+EthnicityEstimation::Count))
157 EthnicityEstimation::getEthnicityScore(
158 EthnicityEstimation::Ethnicities ethnicity
160 return *(&this->africanAmerican +
static_cast<uint32_t
>(ethnicity));
166 inline IAttributeEstimator::EstimationRequest
168 IAttributeEstimator::EstimationRequest first,
169 IAttributeEstimator::EstimationRequest second
171 return static_cast<IAttributeEstimator::EstimationRequest
>(
172 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.