diff --git a/Assets/MediaPipe/Examples/Scripts/DemoGraph.cs b/Assets/MediaPipe/Examples/Scripts/DemoGraph.cs index afc49129d..a9337de5a 100644 --- a/Assets/MediaPipe/Examples/Scripts/DemoGraph.cs +++ b/Assets/MediaPipe/Examples/Scripts/DemoGraph.cs @@ -7,6 +7,7 @@ public abstract class DemoGraph : MonoBehaviour, IDemoGraph { [SerializeField] protected TextAsset config = null; protected const string inputStream = "input_video"; + protected int timestampValue; protected static CalculatorGraph graph; protected static GlCalculatorHelper gpuHelper; @@ -27,6 +28,7 @@ public virtual void Initialize() { } graph = new CalculatorGraph(config.text); + timestampValue = System.Environment.TickCount & System.Int32.MaxValue; } public void Initialize(GpuResources gpuResources, GlCalculatorHelper gpuHelper) { @@ -42,7 +44,7 @@ public virtual Status StartRun(Texture texture) { } public Status PushInput(TextureFrame textureFrame) { - var timestamp = new Timestamp(System.Environment.TickCount & System.Int32.MaxValue); + var timestamp = new Timestamp(++timestampValue); #if !UNITY_ANDROID var imageFrame = new ImageFrame( @@ -86,7 +88,11 @@ static IntPtr PushInputInGlContext() { public void Stop() { if (graph != null) { - graph.CloseInputStream(inputStream).AssertOk(); + var status = graph.CloseAllPacketSources(); + + if (!status.ok) { + Debug.LogError(status.ToString()); + } graph.WaitUntilDone().AssertOk(); } }