浏览代码

tests added, and other PR feedback incorporated

/manual_capture
Mohsen Kamalzadeh 4 年前
当前提交
5cdcabcd
共有 7 个文件被更改,包括 171 次插入78 次删除
  1. 6
      com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
  2. 20
      com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs
  3. 21
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  4. 14
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs
  5. 2
      com.unity.perception/Tests/Editor/DatasetCaptureEditorTests.cs
  6. 146
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs
  7. 40
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs

6
com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs


EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.description)), new GUIContent("Description", "Provide a description for this camera (optional)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.showVisualizations)), new GUIContent("Show Labeler Visualizations", "Display realtime visualizations for labelers that are currently active on this camera."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureRgbImages)),new GUIContent("Save Camera RGB Output to Disk", "For each captured frame, save an RGB image of the camera's output to disk."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureTriggerMode)),new GUIContent("Capture Trigger Mode", $"The method of triggering captures for this camera. In {nameof(PerceptionCamera.CaptureTriggerMode.Scheduled)} mode, captures happen automatically based on a start frame and frame delta time. In {nameof(PerceptionCamera.CaptureTriggerMode.Manual)} mode, captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureTriggerMode)),new GUIContent("Capture Trigger Mode", $"The method of triggering captures for this camera. In {nameof(CaptureTriggerMode.Scheduled)} mode, captures happen automatically based on a start frame and frame delta time. In {nameof(CaptureTriggerMode.Manual)} mode, captures should be triggered manually through calling the {nameof(perceptionCamera.RequestCapture)} method of {nameof(PerceptionCamera)}."));
if (perceptionCamera.captureTriggerMode.Equals(PerceptionCamera.CaptureTriggerMode.Scheduled))
if (perceptionCamera.captureTriggerMode.Equals(CaptureTriggerMode.Scheduled))
{
GUILayout.BeginVertical("TextArea");
EditorGUILayout.LabelField("Scheduled Capture Properties", EditorStyles.boldLabel);

EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.simulationDeltaTime)),new GUIContent(k_FrametimeTitle, $"Sets Unity's Time.{nameof(Time.captureDeltaTime)} to the specified number, causing a fixed number of frames to be generated for each second of elapsed simulation time regardless of the capabilities of the underlying hardware. Thus, simulation time and real time will not be synchronized."));
}
EditorGUILayout.HelpBox($"Captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}.", MessageType.None);
EditorGUILayout.HelpBox($"Captures should be triggered manually through calling the {nameof(perceptionCamera.RequestCapture)} method of {nameof(PerceptionCamera)}.", MessageType.None);
GUILayout.EndVertical();
}

20
com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs


/// <returns>A <see cref="SensorHandle"/>, which should be used to check <see cref="SensorHandle.ShouldCaptureThisFrame"/> each frame to determine whether to capture (or render) that frame.
/// It is also used to report captures, annotations, and metrics on the sensor.</returns>
/// <exception cref="ArgumentException">Thrown if ego is invalid.</exception>
public static SensorHandle RegisterSensor(EgoHandle egoHandle, string modality, string description, float firstCaptureFrame, PerceptionCamera.CaptureTriggerMode captureTriggerMode, float simulationDeltaTime, int framesBetweenCaptures, bool manualSensorAffectSimulationTiming = false)
public static SensorHandle RegisterSensor(EgoHandle egoHandle, string modality, string description, float firstCaptureFrame, CaptureTriggerMode captureTriggerMode, float simulationDeltaTime, int framesBetweenCaptures, bool manualSensorAffectSimulationTiming = false)
{
if (!SimulationState.Contains(egoHandle.Id))
throw new ArgumentException("Supplied ego is not part of the simulation.", nameof(egoHandle));

}
}
/// <summary>
/// Capture trigger modes for sensors.
/// </summary>
public enum CaptureTriggerMode
{
/// <summary>
/// Captures happen automatically based on a start frame and frame delta time.
/// </summary>
Scheduled,
/// <summary>
/// Captures should be triggered manually through calling the manual capture method of the sensor using this trigger mode.
/// </summary>
Manual
}
/// <summary>
/// A handle to a sensor managed by the <see cref="DatasetCapture"/>. It can be used to check whether the sensor
/// is expected to capture this frame and report captures, annotations, and metrics regarding the sensor.

/// <summary>
/// Requests a capture from this sensor on the next rendered frame. Can only be used with manual capture mode (<see cref="PerceptionCamera.CaptureTriggerMode.Manual"/>).
/// </summary>
public void CaptureOnNextUpdate()
public void RequestCapture()
{
DatasetCapture.SimulationState.SetNextCaptureTimeToNowForSensor(this);
}

21
com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs


public int firstCaptureFrame = 0;
/// <summary>
/// Capture trigger modes for <see cref="PerceptionCamera"/>.
/// </summary>
public enum CaptureTriggerMode
{
/// <summary>
/// Captures happen automatically based on a start frame and frame delta time.
/// </summary>
Scheduled,
/// <summary>
/// Captures should be triggered manually through calling the <see cref="PerceptionCamera.CaptureOnNextUpdate"/> method of <see cref="PerceptionCamera"/>.
/// </summary>
Manual
}
/// <summary>
/// The method of triggering captures for this camera.
/// </summary>
public CaptureTriggerMode captureTriggerMode = CaptureTriggerMode.Scheduled;

/// <summary>
/// Requests a capture from this camera on the next rendered frame. Can only be used when using <see cref="PerceptionCamera.CaptureTriggerMode.Manual"/> capture mode.
/// </summary>
public void CaptureOnNextUpdate()
public void RequestCapture()
SensorHandle.CaptureOnNextUpdate();
SensorHandle.RequestCapture();
Debug.LogError($"{nameof(CaptureOnNextUpdate)} can only be used if the camera is in {nameof(CaptureTriggerMode.Manual)} capture mode.");
Debug.LogError($"{nameof(RequestCapture)} can only be used if the camera is in {nameof(CaptureTriggerMode.Manual)} capture mode.");
}
}

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


public string modality;
public string description;
public float firstCaptureTime;
public PerceptionCamera.CaptureTriggerMode captureTriggerMode;
public CaptureTriggerMode captureTriggerMode;
public float renderingDeltaTime;
public int framesBetweenCaptures;
public bool manualSensorAffectSimulationTiming;

m_LastTimeScale = Time.timeScale;
}
public void AddSensor(EgoHandle egoHandle, string modality, string description, float firstCaptureFrame, PerceptionCamera.CaptureTriggerMode captureTriggerMode, float renderingDeltaTime, int framesBetweenCaptures, bool manualSensorAffectSimulationTiming, SensorHandle sensor)
public void AddSensor(EgoHandle egoHandle, string modality, string description, float firstCaptureFrame, CaptureTriggerMode captureTriggerMode, float renderingDeltaTime, int framesBetweenCaptures, bool manualSensorAffectSimulationTiming, SensorHandle sensor)
{
var sensorData = new SensorData()
{

// If the first capture hasn't happened yet, sequenceTimeNextCapture field won't be valid
if (sensorData.firstCaptureTime >= UnscaledSequenceTime)
{
return sensorData.captureTriggerMode == PerceptionCamera.CaptureTriggerMode.Scheduled? sensorData.firstCaptureTime : float.MaxValue;
return sensorData.captureTriggerMode == CaptureTriggerMode.Scheduled? sensorData.firstCaptureTime : float.MaxValue;
}
return sensorData.sequenceTimeOfNextCapture;

if (activeSensor.ShouldCaptureThisFrame)
{
if (sensorData.captureTriggerMode.Equals(PerceptionCamera.CaptureTriggerMode.Scheduled))
if (sensorData.captureTriggerMode.Equals(CaptureTriggerMode.Scheduled))
else if (sensorData.captureTriggerMode.Equals(PerceptionCamera.CaptureTriggerMode.Manual))
else if (sensorData.captureTriggerMode.Equals(CaptureTriggerMode.Manual))
{
sensorData.sequenceTimeOfNextCapture = float.MaxValue;
}

float thisSensorNextFrameDt = -1;
var sensorData = m_Sensors[activeSensor];
if (sensorData.captureTriggerMode.Equals(PerceptionCamera.CaptureTriggerMode.Scheduled))
if (sensorData.captureTriggerMode.Equals(CaptureTriggerMode.Scheduled))
else if (sensorData.captureTriggerMode.Equals(PerceptionCamera.CaptureTriggerMode.Manual) && sensorData.manualSensorAffectSimulationTiming)
else if (sensorData.captureTriggerMode.Equals(CaptureTriggerMode.Manual) && sensorData.manualSensorAffectSimulationTiming)
{
thisSensorNextFrameDt = sensorData.sequenceTimeOfNextRender - UnscaledSequenceTime;
}

2
com.unity.perception/Tests/Editor/DatasetCaptureEditorTests.cs


yield return new EnterPlayMode();
DatasetCapture.ResetSimulation();
var ego = DatasetCapture.RegisterEgo("ego");
var sensor = DatasetCapture.RegisterSensor(ego, "camera", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 0.1f, 0);
var sensor = DatasetCapture.RegisterSensor(ego, "camera", "", 0, CaptureTriggerMode.Scheduled, 0.1f, 0);
sensor.ReportCapture("file.txt", new SensorSpatialData());
expectedDatasetPath = DatasetCapture.OutputDirectory;
yield return new ExitPlayMode();

146
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs


using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.Mathematics;
using Random = UnityEngine.Random;
namespace GroundTruthTests
{

var ego = DatasetCapture.RegisterEgo("ego");
var firstCaptureFrame = 2f;
var simulationDeltaTime = .4f;
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, PerceptionCamera.CaptureTriggerMode.Scheduled, simulationDeltaTime, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, CaptureTriggerMode.Scheduled, simulationDeltaTime, 0);
var startTime = firstCaptureFrame * simulationDeltaTime;
float[] sequenceTimesExpected =

//render the non-captured frames before firstCaptureFrame
yield return null;
}
for (var i = 0; i < sequenceTimesExpected.Length; i++)
{
var sensorData = m_TestHelper.GetSensorData(sensorHandle);

var firstCaptureFrame = 2;
var simulationDeltaTime = .4f;
var framesBetweenCaptures = 2;
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, PerceptionCamera.CaptureTriggerMode.Scheduled, simulationDeltaTime, framesBetweenCaptures);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, CaptureTriggerMode.Scheduled, simulationDeltaTime, framesBetweenCaptures);
var startingFrame = Time.frameCount;
var startTime = firstCaptureFrame * simulationDeltaTime;

int checkedFrame = 0;
var currentSimFrame = Time.frameCount - startingFrame;
while (currentSimFrame <= simulationFramesToCheck[simulationFramesToCheck.Length-1] && checkedFrame < simulationFramesToCheck.Length)
while (currentSimFrame <= simulationFramesToCheck[simulationFramesToCheck.Length - 1] && checkedFrame < simulationFramesToCheck.Length)
{
currentSimFrame = Time.frameCount - startingFrame;
if (currentSimFrame == simulationFramesToCheck[checkedFrame])

yield return null;
}
}
}
[UnityTest]

var firstCaptureFrame = 2f;
var simulationDeltaTime = .4f;
DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, PerceptionCamera.CaptureTriggerMode.Scheduled, simulationDeltaTime, 0);
DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, CaptureTriggerMode.Scheduled, simulationDeltaTime, 0);
float[] deltaTimeSamplesExpected =
{

var timeScale = 2;
Time.timeScale = timeScale;
DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, PerceptionCamera.CaptureTriggerMode.Scheduled, simulationDeltaTime, 0);
DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, CaptureTriggerMode.Scheduled, simulationDeltaTime, 0);
float[] deltaTimeSamplesExpected =
{

public IEnumerator ChangingTimeScale_CausesDebugError()
{
var ego = DatasetCapture.RegisterEgo("ego");
DatasetCapture.RegisterSensor(ego, "cam", "", 2f, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
DatasetCapture.RegisterSensor(ego, "cam", "", 2f, CaptureTriggerMode.Scheduled, 1, 0);
yield return null;
Time.timeScale = 5;

public IEnumerator ChangingTimeScale_DuringStartNewSequence_Succeeds()
{
var ego = DatasetCapture.RegisterEgo("ego");
DatasetCapture.RegisterSensor(ego, "cam", "", 2f, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
DatasetCapture.RegisterSensor(ego, "cam", "", 2f, CaptureTriggerMode.Scheduled, 1, 0);
yield return null;
Time.timeScale = 1;

.01f,
1f
};
DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
DatasetCapture.RegisterSensor(ego, "cam", "", firstCaptureFrame, CaptureTriggerMode.Scheduled, 1, 0);
float[] deltaTimeSamplesExpected =
{

public IEnumerator ResetSimulation_ResetsCaptureDeltaTime()
{
var ego = DatasetCapture.RegisterEgo("ego");
DatasetCapture.RegisterSensor(ego, "cam", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 5, 0);
DatasetCapture.RegisterSensor(ego, "cam", "", 0, CaptureTriggerMode.Scheduled, 5, 0);
yield return null;
Assert.AreEqual(5, Time.captureDeltaTime);
DatasetCapture.ResetSimulation();

[UnityTest]
public IEnumerator ShouldCaptureThisFrame_ReturnsTrueOnProperFrames()
public IEnumerator ShouldCaptureFlagsAndRenderTimesAreCorrectWithMultipleSensors()
var sensor1 = DatasetCapture.RegisterSensor(ego, "cam", "1", firstCaptureFrame1, PerceptionCamera.CaptureTriggerMode.Scheduled, simDeltaTime1, framesBetweenCaptures1);
var sensor1 = DatasetCapture.RegisterSensor(ego, "cam", "1", firstCaptureFrame1, CaptureTriggerMode.Scheduled, simDeltaTime1, framesBetweenCaptures1);
var sensor2 = DatasetCapture.RegisterSensor(ego, "cam", "2", firstCaptureFrame2, PerceptionCamera.CaptureTriggerMode.Scheduled, simDeltaTime2, framesBetweenCaptures2);
var sensor2 = DatasetCapture.RegisterSensor(ego, "cam", "2", firstCaptureFrame2, CaptureTriggerMode.Scheduled, simDeltaTime2, framesBetweenCaptures2);
//Third sensor is a manually triggered one. All it does in this test is affect delta times.
var simDeltaTime3 = 5;
var sensor3 = DatasetCapture.RegisterSensor(ego, "cam", "3", 0, CaptureTriggerMode.Manual, simDeltaTime3, 0, true);
(float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture)[] samplesExpected =
(float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture, bool sensor3ShouldCapture)[] samplesExpected =
(4, false, false),
(2, false, true),
(2, true, false),
(4, false, false),
(4, false, false),
(2, false, true),
(2, true, false)
(4, false, false, false), //Simulation time since sensors created: 4
(1, false, false, false), //5
(1, false, true, false), //6
(2, true, false, false), //8
(2, false, false, false), //10
(2, false, false, false), //12
(3, false, false, false), //15
(1, false, false, false), //16
(2, false, true, false), //18
(2, true, false, false), //20
(4, false, false, false), //24
(1, false, false, false), //25
var samplesActual = new(float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture)[samplesExpected.Length];
var samplesActual = new (float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture, bool sensor3ShouldCapture)[samplesExpected.Length];
samplesActual[i] = (Time.deltaTime, sensor1.ShouldCaptureThisFrame, sensor2.ShouldCaptureThisFrame);
samplesActual[i] = (Time.deltaTime, sensor1.ShouldCaptureThisFrame, sensor2.ShouldCaptureThisFrame, sensor3.ShouldCaptureThisFrame);
[Test]
public void Enabled_StartsTrue()
[UnityTest]
public IEnumerator SequenceTimeOfManualCapture_ReportsCorrectTime_ManualSensorDoesNotAffectTimings()
var sensor1 = DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "cam", "1", 1, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
Assert.IsTrue(sensor1.Enabled);
var ego = DatasetCapture.RegisterEgo("ego");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", 0, CaptureTriggerMode.Manual, 0, 0, false);
var framesToCaptureOn = new List<int>();
var startFrame = Time.frameCount;
var startTime = Time.time;
while (framesToCaptureOn.Count < 10)
{
var randomFrame = Random.Range(startFrame, startFrame + 100);
if(!framesToCaptureOn.Contains(randomFrame))
framesToCaptureOn.Add(randomFrame);
}
framesToCaptureOn.Sort();
var frameIndex = 0;
for (var i = 0; i < framesToCaptureOn.Max(); i++)
{
if (frameIndex == framesToCaptureOn.Count)
break;
if (Time.frameCount == framesToCaptureOn[frameIndex])
{
frameIndex++;
sensorHandle.RequestCapture();
var sensorData = m_TestHelper.GetSensorData(sensorHandle);
var sequenceTimeActual = m_TestHelper.CallSequenceTimeOfNextCapture(sensorData);
var elapsed = Time.time - startTime;
Assert.AreEqual(elapsed, sequenceTimeActual, 0.0001f);
}
yield return null;
}
Assert.AreEqual(frameIndex, framesToCaptureOn.Count, 0.0001f);
}
[UnityTest]
public IEnumerator SequenceTimeOfManualCapture_ReportsCorrectTime_ManualSensorAffectsTimings()
{
var ego = DatasetCapture.RegisterEgo("ego");
var simulationDeltaTime = 0.05f;
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", 0, CaptureTriggerMode.Manual, simulationDeltaTime, 0, true);
var framesToCaptureOn = new List<int>();
var startFrame = Time.frameCount;
var startTime = Time.time;
while (framesToCaptureOn.Count < 10)
{
var randomFrame = Random.Range(startFrame, startFrame + 100);
if(!framesToCaptureOn.Contains(randomFrame))
framesToCaptureOn.Add(randomFrame);
}
framesToCaptureOn.Sort();
float[] sequenceTimesExpected = new float[framesToCaptureOn.Count];
for (int i = 0; i < sequenceTimesExpected.Length; i++)
{
sequenceTimesExpected[i] = (framesToCaptureOn[i] - startFrame) * simulationDeltaTime;
}
var frameIndex = 0;
for (var i = 0; i < framesToCaptureOn.Max(); i++)
{
if (frameIndex == framesToCaptureOn.Count)
break;
if (Time.frameCount == framesToCaptureOn[frameIndex])
{
sensorHandle.RequestCapture();
var sensorData = m_TestHelper.GetSensorData(sensorHandle);
var sequenceTimeActual = m_TestHelper.CallSequenceTimeOfNextCapture(sensorData);
Assert.AreEqual(sequenceTimesExpected[frameIndex], sequenceTimeActual, 0.0001f);
frameIndex++;
}
yield return null;
}
Assert.AreEqual(frameIndex, framesToCaptureOn.Count, 0.0001f);
}
}
}

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


}}";
var ego = DatasetCapture.RegisterEgo(egoDescription);
var sensorHandle = DatasetCapture.RegisterSensor(ego, modality, sensorDescription, 1, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, modality, sensorDescription, 1, CaptureTriggerMode.Scheduled, 1, 0);
Assert.IsTrue(sensorHandle.IsValid);
DatasetCapture.ResetSimulation();
Assert.IsFalse(sensorHandle.IsValid);

}}";
var ego = DatasetCapture.RegisterEgo("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "camera", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "camera", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
var sensorSpatialData = new SensorSpatialData(new Pose(egoPosition, egoRotation), new Pose(position, rotation), egoVelocity, null);
sensorHandle.ReportCapture(filename, sensorSpatialData, ("camera_intrinsic", intrinsics));

};
var ego = DatasetCapture.RegisterEgo("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 2, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 2, 0);
var sensorSpatialData = new SensorSpatialData(default, default, null, null);
Assert.IsTrue(sensorHandle.ShouldCaptureThisFrame);
sensorHandle.ReportCapture("f", sensorSpatialData);

]";
var ego = DatasetCapture.RegisterEgo("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
sensorHandle.ReportCapture(filename, default);
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("semantic segmentation", "pixel-wise semantic segmentation label", "PNG", annotationDefinitionGuid);
sensorHandle.ReportAnnotationFile(annotationDefinition, "annotations/semantic_segmentation_000.png");

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
sensorHandle.ReportAnnotationValues(annotationDefinition, values);
DatasetCapture.ResetSimulation();

{
var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, CaptureTriggerMode.Scheduled, 1, 0);
Assert.Throws<InvalidOperationException>(() => sensorHandle.ReportAnnotationFile(annotationDefinition, ""));
}

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, CaptureTriggerMode.Scheduled, 1, 0);
Assert.Throws<InvalidOperationException>(() => sensorHandle.ReportAnnotationValues(annotationDefinition, new int[0]));
}

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, CaptureTriggerMode.Scheduled, 1, 0);
Assert.Throws<InvalidOperationException>(() => sensorHandle.ReportAnnotationAsync(annotationDefinition));
}

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
sensorHandle.ReportAnnotationAsync(annotationDefinition);
DatasetCapture.ResetSimulation();
LogAssert.Expect(LogType.Error, new Regex("Simulation ended with pending .*"));

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
var asyncAnnotation = sensorHandle.ReportAnnotationAsync(annotationDefinition);
Assert.IsTrue(asyncAnnotation.IsValid);

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
var asyncAnnotation = sensorHandle.ReportAnnotationAsync(annotationDefinition);
Assert.IsTrue(asyncAnnotation.IsPending);

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
var asyncAnnotation = sensorHandle.ReportAnnotationAsync(annotationDefinition);
Assert.IsTrue(asyncAnnotation.IsPending);

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
// Record one capture for this frame
sensorHandle.ReportCapture(fileName, default);

{
var ego = DatasetCapture.RegisterEgo("");
var metricDefinition = DatasetCapture.RegisterMetricDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, CaptureTriggerMode.Scheduled, 1, 0);
Assert.Throws<InvalidOperationException>(() => sensorHandle.ReportMetric(metricDefinition, new int[0]));
}

var ego = DatasetCapture.RegisterEgo("");
var metricDefinition = DatasetCapture.RegisterMetricDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 100, CaptureTriggerMode.Scheduled, 1, 0);
Assert.Throws<InvalidOperationException>(() => sensorHandle.ReportMetricAsync(metricDefinition));
}

var ego = DatasetCapture.RegisterEgo("");
var metricDefinition = DatasetCapture.RegisterMetricDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
sensorHandle.ReportMetricAsync(metricDefinition);
DatasetCapture.ResetSimulation();
LogAssert.Expect(LogType.Error, new Regex("Simulation ended with pending .*"));

var ego = DatasetCapture.RegisterEgo("");
var metricDefinition = DatasetCapture.RegisterMetricDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
var asyncMetric = sensorHandle.ReportMetricAsync(metricDefinition);
Assert.IsTrue(asyncMetric.IsValid);

var expectedLine = @"""step"": 0";
var metricDefinition = DatasetCapture.RegisterMetricDefinition("");
DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
yield return null;
yield return null;

var expectedLine = @"""step"": 0";
var metricDefinition = DatasetCapture.RegisterMetricDefinition("");
var sensor = DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensor = DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
yield return null;
sensor.ReportMetric(metricDefinition, values);

}}";
var metricDefinition = DatasetCapture.RegisterMetricDefinition("");
var sensor = DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "", "", 0, PerceptionCamera.CaptureTriggerMode.Scheduled, 1, 0);
var sensor = DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "", "", 0, CaptureTriggerMode.Scheduled, 1, 0);
var annotation = sensor.ReportAnnotationFile(DatasetCapture.RegisterAnnotationDefinition(""), "");
var valuesJsonArray = JArray.FromObject(values).ToString(Formatting.Indented);
if (async)

正在加载...
取消
保存