There's now an example on how to apply detected expressions to a VRM model.

This commit is contained in:
Emiliana 2020-02-11 09:55:31 +01:00
parent 443a7ee88e
commit 1f3bf30166
3 changed files with 55 additions and 2 deletions

View file

@ -0,0 +1,53 @@
using System.Collections.Generic;
using UnityEngine;
using VRM;
namespace OpenSee {
public class OpenSeeVRMExpression : MonoBehaviour
{
public OpenSeeExpression openSeeExpression;
public VRMBlendShapeProxy vrmBlendShapeProxy;
public string expressionNeutral = "neutral";
public string expressionFun = "smile";
public string expressionSorrow = "sad";
public string expressionAngry = "angry";
public string expressionJoy = "shocked";
private BlendShapeKey lastKey;
private string lastExpression = "";
void Start()
{
}
void Update()
{
if (openSeeExpression == null || vrmBlendShapeProxy == null) {
return;
}
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Neutral), 0f);
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Fun), 0f);
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Sorrow), 0f);
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Angry), 0f);
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Joy), 0f);
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Blink_R), 0f);
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Blink_L), 0f);
if (openSeeExpression.expression == expressionFun) {
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Fun), 1f);
return;
} else if (openSeeExpression.expression == expressionSorrow) {
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Sorrow), 1f);
return;
} else if (openSeeExpression.expression == expressionAngry) {
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Angry), 1f);
return;
} else if (openSeeExpression.expression == expressionJoy) {
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Joy), 1f);
return;
}
vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Neutral), 1f);
}
}
}

View file

@ -29,7 +29,7 @@ public class OpenSeeLauncher : MonoBehaviour {
[Tooltip("The path, where the .onnx model files can be found")]
public string modelPath = "models\\";
[Tooltip("Additional options that should be passed to the face tracker.")]
public string[] commandlineOptions = new string[] { "--silent", "1", "--max-threads", "2", "--model", "1" };
public List<string> commandlineOptions = new List<string>(new string[] { "--silent", "1", "--max-threads", "2", "--model", "3" });
[Header("Runtime information")]
[Tooltip("This field shows if the tracker is currently alive.")]
public bool trackerAlive = false;

View file

@ -143,7 +143,7 @@ public class SVMModel {
maxClasses = max + 1;
this.cols = cols;
model = trainModel(features, labels, rows, cols, 32f);
model = trainModel(features, labels, rows, cols, 12f);
haveModel = true;
return true;