ANSFR: emit numeric AgeYears in face attributes; clearer demo overlays
- FaceAttributeToJsonString now adds "AgeYears":"<n>" beside the existing "Age" bucket (Kids/Young Adults/Adults/Elders) - additive key, existing consumers parsing "Age" are unaffected. - Classroom demo overlay: explicit per-line labels (Gender: / Age: / Emotion:) and the numeric age in parentheses, e.g. "Age: Adults (28)". Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1891,7 +1891,7 @@ int ClassroomAttributesVideoTest()
|
||||
|
||||
// extra_info is itself a JSON string:
|
||||
// {"attributes":[{"Gender":..,"Age":..,"Emotion":..,"Pose(r,p,y)":..}]}
|
||||
std::string gender, age, emotion;
|
||||
std::string gender, age, ageYears, emotion;
|
||||
const auto extra = GetData<std::string>(r, "extra_info");
|
||||
if (!extra.empty()) {
|
||||
try {
|
||||
@@ -1900,15 +1900,18 @@ int ClassroomAttributesVideoTest()
|
||||
boost::property_tree::read_json(ess, ept);
|
||||
if (ept.count("attributes")) {
|
||||
for (const auto& attr : ept.get_child("attributes")) {
|
||||
gender = GetOptionalValue<std::string>(attr.second, "Gender", "");
|
||||
age = GetOptionalValue<std::string>(attr.second, "Age", "");
|
||||
emotion = GetOptionalValue<std::string>(attr.second, "Emotion", "");
|
||||
gender = GetOptionalValue<std::string>(attr.second, "Gender", "");
|
||||
age = GetOptionalValue<std::string>(attr.second, "Age", "");
|
||||
ageYears = GetOptionalValue<std::string>(attr.second, "AgeYears", "");
|
||||
emotion = GetOptionalValue<std::string>(attr.second, "Emotion", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
if (!ageYears.empty())
|
||||
age += " (" + ageYears + ")";
|
||||
|
||||
const bool known = (name != "Unknown");
|
||||
const cv::Scalar boxColor = known ? cv::Scalar(0, 255, 0) : cv::Scalar(0, 200, 255);
|
||||
@@ -1916,10 +1919,12 @@ int ClassroomAttributesVideoTest()
|
||||
|
||||
std::vector<std::string> lines;
|
||||
lines.push_back(name);
|
||||
if (!gender.empty() || !age.empty())
|
||||
lines.push_back(gender + " / " + age);
|
||||
if (!gender.empty())
|
||||
lines.push_back("Gender: " + gender);
|
||||
if (!age.empty())
|
||||
lines.push_back("Age: " + age);
|
||||
if (!emotion.empty())
|
||||
lines.push_back(emotion);
|
||||
lines.push_back("Emotion: " + emotion);
|
||||
|
||||
int ty = y - 8 - 18 * static_cast<int>(lines.size() - 1);
|
||||
for (const auto& line : lines) {
|
||||
|
||||
Reference in New Issue
Block a user