浏览代码

fixed wrong pending capture being chosen for an async annotation after starting a new data capture sequence

/usim-randomization
Steven Leal 4 年前
当前提交
444d404c
共有 3 个文件被更改,包括 43 次插入4 次删除
  1. 8
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs
  2. 2
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
  3. 37
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs

8
com.unity.perception/Runtime/GroundTruth/SimulationState.cs


throw new InvalidOperationException("AsyncAnnotation has already been reported and cannot be reported again.");
PendingCapture pendingCapture = null;
int annotationIndex = -1;
break;
annotationIndex = pendingCapture.Annotations.FindIndex(a => a.Item1.Equals(asyncAnnotation.Annotation));
if (annotationIndex != -1)
break;
Debug.Assert(pendingCapture != null);
Debug.Assert(pendingCapture != null && annotationIndex != -1);
var annotationIndex = pendingCapture.Annotations.FindIndex(a => a.Item1.Equals(asyncAnnotation.Annotation));
var annotationTuple = pendingCapture.Annotations[annotationIndex];
var annotationData = annotationTuple.Item2;

2
com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs


while (!isScenarioComplete)
{
// DatasetCapture.StartNewSequence();
DatasetCapture.StartNewSequence();
foreach (var config in ParameterConfiguration.configurations)
config.ApplyParameters(currentIteration, ParameterApplicationFrequency.OnIterationSetup);
OnIterationSetup();

37
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
using System.Linq;

FileAssert.Exists(capturesPath);
StringAssert.Contains(TestHelper.NormalizeJson(expectedAnnotation), EscapeGuids(File.ReadAllText(capturesPath)));
}
[UnityTest]
public IEnumerator AnnotationAsyncReportResult_FindsCorrectPendingCaptureAfterStartingNewSequence()
{
const string fileName = "my/file.png";
var value = new[]
{
new TestValues()
{
a = "a string",
b = 10
}
};
var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0);
// Record one capture for this frame
sensorHandle.ReportCapture(fileName, default);
// Wait one frame
yield return null;
// Reset the capture step
DatasetCapture.StartNewSequence();
// Record a new capture on different frame that has the same step (0) as the first capture
sensorHandle.ReportCapture(fileName, default);
// Confirm that the annotation correctly skips the first pending capture to write to the second
var asyncAnnotation = sensorHandle.ReportAnnotationAsync(annotationDefinition);
Assert.DoesNotThrow(() => asyncAnnotation.ReportValues(value));
DatasetCapture.ResetSimulation();
}
[Test]

正在加载...
取消
保存