Face Estimation
In this section you will learn how to integrate Emotion, Age, Gender and Mask estimators to your C++ or Python project.
Estimation Blocks (C++/Python)
Types of Estimation Blocks for the Key "unit_type"
- EMOTION_ESTIMATOR
- GENDER_ESTIMATOR
- AGE_ESTIMATOR
- MASK_ESTIMATOR
Dependencies on Other Blocks
- Results of the detection unit operation.
- Some blocks require face points obtained from the FACE_FITTER block.
1. Create an Estimation Block
1.1 To create an estimation block, follow steps 1-3 described in Creating a Processing Block
and specify the value of the block you are interested in for the key "unit_type".
- C++
- Python
configCtx["unit_type"] = "EMOTION_ESTIMATOR";
configCtx = {
"unit_type": "EMOTION_ESTIMATOR",
}
1.2 Create an Estimation processing block:
- C++
- Python
- Flutter
pbio::ProcessingBlock blockEstimator = service->createProcessingBlock(configCtx);
blockEstimator = service.create_processing_block(configCtx)
ProcessingBlock blockEstimator = service.createProcessingBlock({
"unit_type": "EMOTION_ESTIMATOR",
});
2. Attribute Estimation
2.1 Follow steps 1-4 of Face, Body and Object Detection section
2.2 Call blockEstimator() and pass a Context-container ioData:
- C++
- Python
- Flutter
blockEstimator(ioData);
blockEstimator(ioData)
ioData result = blockEstimator.process(ioData);
Calling blockEstimator() will add the result of processing samples (images) to the container ioData.
Attributes corresponding to the estimation block are added to each object from the list of objects available by the key "objects".
3. Add Attributes
3.1 EMOTION_ESTIMATOR
/*
[{
"emotions" : [
"confidence": {"type": "double", "minimum": 0, "maximum": 1},
"emotion": {
"enum": ["ANGRY", "DISGUSTED", "SCARED", "HAPPY", "NEUTRAL", "SAD", "SURPRISED"]
}
]
}]
*/
3.2 AGE_ESTIMATOR
/*
[{
"age": {"type": "long", "minimum": 0}
}]
*/
3.3 GENDER_ESTIMATOR
/*
[{
"gender": {
"enum": ["FEMALE", "MALE"]
}
}]
*/
3.4 MASK_ESTIMATOR
/*
[{
"has_medical_mask": {
"confidence": {"double", "minimum": 0, "maximum": 1}, // numerical value of confidence in the presence/absence of a mask on the face
"value": {"type": "boolean"} // true - masked face, false - unmasked face. The "value" parameter is determined by the value of the `confidence_threshold` key
}
}]
*/