Skip to content

Commit 0ed4848

Browse files
committed
fix: 🐛 Improve eye tracking stability (?)
1 parent 516e8cc commit 0ed4848

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

ViveStreamingEyes.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,33 @@ public void Update(string status)
3636
}
3737
}
3838

39+
private float _timeSinceLastValidEyeData = float.MaxValue;
3940
private readonly EyeData eyeData = new();
4041

4142
public ViveStreamingEyes(InputInterface input) : base(input, "Vive Streaming Eye Tracking", true)
4243
{
4344
}
4445

45-
public void UpdateInputs(bool connected, ref string? newData)
46+
public void UpdateInputs(bool connected, ref string? newData, float deltaTime)
4647
{
47-
IsEyeTrackingActive = IsDeviceActive = LeftEye.IsDeviceActive = RightEye.IsDeviceActive = CombinedEye.IsDeviceActive = connected;
48-
SetTracking(connected && Input.VR_Active);
48+
//IsDeviceActive = LeftEye.IsDeviceActive = RightEye.IsDeviceActive = CombinedEye.IsDeviceActive = connected;
49+
IsEyeTrackingActive = connected && Input.VR_Active;
4950

50-
if (newData is null || !IsDeviceActive || !IsTracking)
51+
_timeSinceLastValidEyeData += deltaTime;
52+
53+
if (newData is null)
5154
{
55+
if (_timeSinceLastValidEyeData > 0.2f)
56+
{
57+
SetTracking(false);
58+
}
59+
5260
return;
5361
}
5462

63+
SetTracking(true);
64+
_timeSinceLastValidEyeData = 0f;
65+
5566
eyeData.Update(newData);
5667
newData = null;
5768

ViveStreamingFaceTrackingDriver.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ private static void OnDebugLog(string message)
140140

141141
public void UpdateInputs(float deltaTime)
142142
{
143+
144+
if (!connected && _tracking)
145+
{
146+
VS_PC_SDK.VS_StopFaceTracking();
147+
_tracking = false;
148+
}
149+
143150
if (connected && !_tracking && active)
144151
{
145152
if (!VS_PC_SDK.VS_StartFaceTracking())
@@ -165,7 +172,7 @@ public void UpdateInputs(float deltaTime)
165172
_tracking = false;
166173
}
167174

168-
eyes?.UpdateInputs(connected, ref eyeData);
175+
eyes?.UpdateInputs(connected, ref eyeData, deltaTime);
169176
mouth?.UpdateInputs(connected, ref lipData);
170177
}
171178

0 commit comments

Comments
 (0)