Skip to content

Commit

Permalink
fix(example): timestamp can be same as the previous one on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
homuler committed Jan 21, 2021
1 parent 6a0e22c commit 411fc68
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Assets/MediaPipe/Examples/Scripts/DemoGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public abstract class DemoGraph : MonoBehaviour, IDemoGraph<TextureFrame> {
[SerializeField] protected TextAsset config = null;

protected const string inputStream = "input_video";
protected int timestampValue;
protected static CalculatorGraph graph;
protected static GlCalculatorHelper gpuHelper;

Expand All @@ -27,6 +28,7 @@ public abstract class DemoGraph : MonoBehaviour, IDemoGraph<TextureFrame> {
}

graph = new CalculatorGraph(config.text);
timestampValue = System.Environment.TickCount & System.Int32.MaxValue;
}

public void Initialize(GpuResources gpuResources, GlCalculatorHelper gpuHelper) {
Expand All @@ -42,7 +44,7 @@ public abstract class DemoGraph : MonoBehaviour, IDemoGraph<TextureFrame> {
}

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(
Expand Down Expand Up @@ -86,7 +88,11 @@ public abstract class DemoGraph : MonoBehaviour, IDemoGraph<TextureFrame> {

public void Stop() {
if (graph != null) {
graph.CloseInputStream(inputStream).AssertOk();
var status = graph.CloseAllPacketSources();

if (!status.ok) {
Debug.LogError(status.ToString());
}
graph.WaitUntilDone().AssertOk();
}
}
Expand Down

0 comments on commit 411fc68

Please sign in to comment.