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>
101 estimate(
const Image& warp,
const EstimationRequest request, EstimationResult& out)
const noexcept = 0;
115 virtual ResultValue<FSDKError, EstimationResult> estimate(
116 Span<const Image> warps,
117 const EstimationRequest request,
118 Span<EstimationResult> results)
const noexcept = 0;
132 virtual Result<FSDKError> validate(
133 Span<const Image> warps,
134 const EstimationRequest request,
135 Span<Result<FSDKError>> errors) const noexcept = 0;
141 using EstimationRequest = IAttributeEstimator::EstimationRequest;
142 using AttributeEstimationResult = IAttributeEstimator::EstimationResult;
147 EthnicityEstimation::Ethnicities EthnicityEstimation::getPredominantEthnicity()
const {
148 const float* arr = &this->africanAmerican;
149 return static_cast<EthnicityEstimation::Ethnicities
>(
150 std::distance(arr, std::max_element(arr, arr + EthnicityEstimation::Count)));
156 float EthnicityEstimation::getEthnicityScore(EthnicityEstimation::Ethnicities ethnicity)
const {
157 return *(&this->africanAmerican +
static_cast<uint32_t
>(ethnicity));
163 inline IAttributeEstimator::EstimationRequest
164 operator|(IAttributeEstimator::EstimationRequest first, IAttributeEstimator::EstimationRequest second) {
165 return static_cast<IAttributeEstimator::EstimationRequest
>(
166 static_cast<int>(first) | static_cast<int>(second));
#define DECLARE_SMARTPTR(X)
Smart ptr declaration helper macro.
Definition: Def.h:56
Common data types and structures.
Object system types and interfaces.