Changed the simple expression detection sensitivity to make more sense.

This commit is contained in:
Emiliana 2020-08-22 00:52:35 +02:00
parent 5d0f916ee0
commit 8c079f4e9b

View file

@ -20,8 +20,8 @@ public class OpenSeeExpression : MonoBehaviour
[Range(0f, 1f)] [Range(0f, 1f)]
public float simpleSmoothing = 0.6f; public float simpleSmoothing = 0.6f;
[Tooltip("This smoothing factor is applied to the features used for simple expression detection.")] [Tooltip("This smoothing factor is applied to the features used for simple expression detection.")]
[Range(-1f, 1f)] [Range(0f, 5f)]
public float simpleSensitivity = 0f; public float simpleSensitivity = 1f;
[Header("Calibration")] [Header("Calibration")]
[Tooltip("This specifies which expression calibration data should be collected for.")] [Tooltip("This specifies which expression calibration data should be collected for.")]
public string calibrationExpression = "neutral"; public string calibrationExpression = "neutral";
@ -89,24 +89,24 @@ public class OpenSeeExpression : MonoBehaviour
private bool hadSurprised = false; private bool hadSurprised = false;
float AdjustThreshold(bool active) { float AdjustThreshold(bool active) {
if (active) if (active)
return Mathf.Clamp(0.8f - simpleSensitivity, -1f, 1f); return 0.8f;
else else
return Mathf.Clamp(1f - simpleSensitivity, -1f, 1f); return 1f;
} }
void ThresholdDetection() { void ThresholdDetection() {
lastMouthCorner = lastMouthCorner * simpleSmoothing + (openSeeData.features.MouthCornerUpDownLeft + openSeeData.features.MouthCornerUpDownRight) * 0.5f * (1f - simpleSmoothing); lastMouthCorner = lastMouthCorner * simpleSmoothing + (openSeeData.features.MouthCornerUpDownLeft + openSeeData.features.MouthCornerUpDownRight) * 0.5f * (1f - simpleSmoothing);
lastEyebrows = lastEyebrows * simpleSmoothing + (openSeeData.features.EyebrowUpDownLeft + openSeeData.features.EyebrowUpDownRight) * 0.5f * (1f - simpleSmoothing); lastEyebrows = lastEyebrows * simpleSmoothing + (openSeeData.features.EyebrowUpDownLeft + openSeeData.features.EyebrowUpDownRight) * 0.5f * (1f - simpleSmoothing);
if (lastMouthCorner < -0.2f * AdjustThreshold(hadFun)) { if (lastMouthCorner * simpleSensitivity < -0.2f * AdjustThreshold(hadFun)) {
expression = "fun"; expression = "fun";
hadFun = true; hadFun = true;
hadSurprised = false; hadSurprised = false;
hadAngry = false; hadAngry = false;
} else if (lastEyebrows > 0.2f * AdjustThreshold(hadSurprised)) { } else if (lastEyebrows * simpleSensitivity > 0.2f * AdjustThreshold(hadSurprised)) {
expression = "surprise"; expression = "surprise";
hadFun = false; hadFun = false;
hadSurprised = true; hadSurprised = true;
hadAngry = false; hadAngry = false;
} else if (lastEyebrows < -0.2f * AdjustThreshold(hadAngry) && lastMouthCorner > -0.3f * (2f - AdjustThreshold(hadAngry))) { } else if (lastEyebrows * simpleSensitivity < -0.25f * AdjustThreshold(hadAngry) && lastMouthCorner * simpleSensitivity > -0.3f * (2f - AdjustThreshold(hadAngry))) {
expression = "angry"; expression = "angry";
hadFun = false; hadFun = false;
hadSurprised = false; hadSurprised = false;