From cf49ba5468d5f81ddadb83a8cf586f9aa8edcce5 Mon Sep 17 00:00:00 2001 From: Emiliana <38952746+emilianavt@users.noreply.github.com> Date: Mon, 30 Mar 2020 16:44:33 +0200 Subject: [PATCH] Unity components that rely on 3D points now ignore tracking data for frames with high 3D fitting error. --- Examples/OpenSeeVRMDriver.cs | 5 ++++- Unity/OpenSee.cs | 3 +++ Unity/OpenSeeIKTarget.cs | 2 +- Unity/OpenSeeLauncher.cs | 5 +++-- Unity/OpenSeeShowPoints.cs | 2 +- facetracker.py | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Examples/OpenSeeVRMDriver.cs b/Examples/OpenSeeVRMDriver.cs index b8482e7..44080cf 100644 --- a/Examples/OpenSeeVRMDriver.cs +++ b/Examples/OpenSeeVRMDriver.cs @@ -829,8 +829,11 @@ void Start() { } void RunUpdates() { - if (openSeeExpression != null && openSeeExpression.openSee != null) + if (openSeeExpression != null && openSeeExpression.openSee != null) { openSeeData = openSeeExpression.openSee.GetOpenSeeData(openSeeExpression.faceId); + if (openSeeData.fit3DError > openSeeExpression.openSee.maxFit3DError) + openSeeData = null; + } if (initializeLipSync) { InitializeLipSync(); initializeLipSync = false; diff --git a/Unity/OpenSee.cs b/Unity/OpenSee.cs index f458688..ef5f00a 100644 --- a/Unity/OpenSee.cs +++ b/Unity/OpenSee.cs @@ -23,6 +23,9 @@ public class OpenSee : MonoBehaviour { public int receivedPackets = 0; [Tooltip("This contains the actual tracking data")] public OpenSeeData[] trackingData = null; + + [HideInInspector] + public float maxFit3DError = 100f; [System.Serializable] public class OpenSeeData { diff --git a/Unity/OpenSeeIKTarget.cs b/Unity/OpenSeeIKTarget.cs index ca439cc..d2dfc5e 100644 --- a/Unity/OpenSeeIKTarget.cs +++ b/Unity/OpenSeeIKTarget.cs @@ -70,7 +70,7 @@ Vector3 MirrorTranslation(Vector3 v) { void RunUpdate() { var openSeeData = openSee.GetOpenSeeData(faceId); - if (openSeeData == null) + if (openSeeData == null || openSeeData.fit3DError > openSee.maxFit3DError) return; if (openSeeData.time > updated) { updated = openSeeData.time; diff --git a/Unity/OpenSeeLauncher.cs b/Unity/OpenSeeLauncher.cs index 8100a56..29be64d 100644 --- a/Unity/OpenSeeLauncher.cs +++ b/Unity/OpenSeeLauncher.cs @@ -134,8 +134,6 @@ private string[] EscapiListCameras_x86() { } public string[] ListCameras() { - if (!CheckSetup(false)) - return null; if (usePinvoke || usePinvokeListCameras) { if (Environment.Is64BitProcess) return EscapiListCameras_x64(); @@ -143,6 +141,9 @@ public string[] ListCameras() { return EscapiListCameras_x86(); } + if (!CheckSetup(false)) + return null; + StringBuilder stringBuilder; ProcessStartInfo processStartInfo; Process process; diff --git a/Unity/OpenSeeShowPoints.cs b/Unity/OpenSeeShowPoints.cs index 77d2f2e..bd7b1ea 100644 --- a/Unity/OpenSeeShowPoints.cs +++ b/Unity/OpenSeeShowPoints.cs @@ -59,7 +59,7 @@ void Update () { if (openSeeData == null || openSeeData.Length < 1) return;*/ openSeeData = openSee.GetOpenSeeData(faceId); - if (openSeeData == null) + if (openSeeData == null || (show3DPoints && openSeeData.fit3DError > openSee.maxFit3DError)) return; if (openSeeData.time > updated) { updated = openSeeData.time; diff --git a/facetracker.py b/facetracker.py index 6966d2b..32226d3 100644 --- a/facetracker.py +++ b/facetracker.py @@ -27,7 +27,7 @@ parser.add_argument("--video-out", help="Set this to the filename of an AVI file to save the tracking visualization as a video", default=None) parser.add_argument("--raw-rgb", type=int, help="When this is set, raw RGB frames of the size given with \"-W\" and \"-H\" are read from standard input instead of reading a video", default=0) parser.add_argument("--log-data", help="You can set a filename to which tracking data will be logged here", default="") -parser.add_argument("--model", type=int, help="This can be used to select the tracking model. Higher numbers are models with better tracking quality, but slower speed. The recommended models are 3 and 1.", default=3, choices=[0, 1, 2, 3]) +parser.add_argument("--model", type=int, help="This can be used to select the tracking model. Higher numbers are models with better tracking quality, but slower speed. Models 1 and 0 tend to be too rigid for expression and blink detection.", default=3, choices=[0, 1, 2, 3]) parser.add_argument("--model-dir", help="This can be used to specify the path to the directory containing the .onnx model files", default=None) parser.add_argument("--gaze-tracking", type=int, help="When set to 1, experimental blink detection and gaze tracking are enabled, which makes things slightly slower", default=1) parser.add_argument("--face-id-offset", type=int, help="When set, this offset is added to all face ids, which can be useful for mixing tracking data from multiple network sources", default=0)