ANSFR: report v1.4 emotion class names verbatim in the attribute JSON

The legacy display remap in FaceAttributeToJsonString rewrote most
emotions to "Attentive", which hid the v1.4 classifier's real classes.
The remap now applies ONLY to the legacy OpenVINO model's lowercase
classes (sad/happy/neutral/anger/surprise - v1.1 output unchanged);
every other name, i.e. the classes read from emotionsrecognition.names
(Angry, Fear, Happy, Neutral, Sad), passes through verbatim. A retrained
classifier with a different .names list needs no code change.

Verified on the classroom video: faces previously labelled "Attentive"
now read "Angry (100%)"; smiling faces read "Happy (100%)". Parity test
updated to check each pack against its own emotion vocabulary.

Note for client code: v1.4 deployments no longer emit "Attentive" -
anything matching that string must handle Angry/Fear/Sad instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-28 16:50:47 +10:00
co-authored by Claude Fable 5
parent 024d55197b
commit 430c8057b8
2 changed files with 23 additions and 24 deletions
+9 -17
View File
@@ -646,29 +646,21 @@ namespace ANSCENTER {
if (face.isEmotionsEnabled()) {
const auto& [emotionName, emotionConfidence] = face.getMainEmotion();
std::ostringstream emotionStr;
// The v1.4 ONNX classifier's classes (emotionsrecognition.names:
// Angry, Fear, Happy, Neutral, Sad) are reported VERBATIM. Only
// the legacy OpenVINO model's lowercase classes keep the
// historical display remap so v1.1 output is unchanged.
std::string adjustedEmotionName = emotionName;
if (emotionName == "Sad" || emotionName == "sad")
if (emotionName == "sad")
adjustedEmotionName = "Attentive";
else if (emotionName == "Happy" || emotionName == "happy")
else if (emotionName == "happy")
adjustedEmotionName = "Happy";
else if (emotionName == "Neutral" || emotionName == "neutral")
else if (emotionName == "neutral")
adjustedEmotionName = "Neutral";
else if (emotionName == "Angry" || emotionName == "angry")
else if (emotionName == "anger")
adjustedEmotionName = "Attentive";
else if (emotionName == "Surprised" || emotionName == "surprised")
else if (emotionName == "surprise")
adjustedEmotionName = "Attentive";
else if (emotionName == "Surprise" || emotionName == "surprise")
adjustedEmotionName = "Attentive";
else if (emotionName == "Disgusted" || emotionName == "disgusted")
adjustedEmotionName = "Attentive";
else if (emotionName == "Fearful" || emotionName == "fearful")
adjustedEmotionName = "Attentive";
else if (emotionName == "Fear" || emotionName == "fear")
adjustedEmotionName = "Attentive";
else if (emotionName == "Anger" || emotionName == "anger")
adjustedEmotionName = "Attentive";
else
adjustedEmotionName = "Neutral";
emotionStr << adjustedEmotionName << " (" << static_cast<int>(emotionConfidence * 100) << "%)";
detectedNode.put("Emotion", emotionStr.str());