浏览代码

more progress

/manual_capture
Mohsen Kamalzadeh 4 年前
当前提交
86644d1a
共有 7 个文件被更改,包括 120 次插入56 次删除
  1. 47
      com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
  2. 4
      com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs
  3. 42
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  4. 19
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs
  5. 2
      com.unity.perception/Tests/Editor/DatasetCaptureEditorTests.cs
  6. 22
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs
  7. 40
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs

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


using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;

serializedObject.ApplyModifiedProperties();
}
string onlyRenderCaptTitle = "Only Render Captured Frames";
string periodTilte = "Capture and Render Interval";
string frametimeTitle = "Rendering Frame Time";
int startFrame;
public override void OnInspectorGUI()
{
using(new EditorGUI.DisabledScope(EditorApplication.isPlaying))

EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureRgbImages)),new GUIContent("Save Camera Output to Disk", "For each captured frame, save an RGB image of the perception camera's output to disk."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureTriggerMode)),new GUIContent("Scheduled Capture", ""));
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 time/frame and time/frame interval. In {nameof(PerceptionCamera.CaptureTriggerMode.Manual)} mode, captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}."));
GUILayout.BeginVertical("Box");
GUILayout.BeginVertical("TextArea");
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.startTime)), new GUIContent("Start Time","Time at which this perception camera starts rendering and capturing (seconds)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.period)), new GUIContent("Capture Interval", "The interval at which the perception camera should render and capture (seconds)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.onlyRenderCapturedFrames)),new GUIContent("Only Render Captured Frames", ""));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.onlyRenderCapturedFrames)),new GUIContent(onlyRenderCaptTitle, $"If this checkbox is enabled, the attached camera will only render those frames that it needs to capture. In addition, the global frame delta time will be altered to match this camera's capture period, thus, the scene will not be visually updated in-between captures (physics simulation is unaffected). Therefore, if you have more than one {nameof(PerceptionCamera)} active, this flag should be either disabled or enabled for all of them, otherwise the cameras will not capture and synchronize properly."));
if (perceptionCamera.onlyRenderCapturedFrames)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.startTime)), new GUIContent("Start Time","Time at which this perception camera starts rendering and capturing (seconds)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.period)), new GUIContent(periodTilte, "The interval at which the perception camera should render and capture (seconds)."));
EditorGUILayout.HelpBox($"First capture at {perceptionCamera.startTime} seconds and consecutive captures every {perceptionCamera.period} seconds", MessageType.None);
}
else
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.renderingDeltaTime)),new GUIContent(frametimeTitle, "The rendering frame time (seconds). E.g. 0.0166 translates to 60 frames per second."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.startFrame)), new GUIContent("Start at Frame",$"Frame number at which this camera starts capturing."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.framesBetweenCaptures)),new GUIContent("Frames between captures", "The number of frames to render between the camera's scheduled captures. Setting this to 0 makes the camera capture every rendered frame."));
//Because start time only needs to be calculated once, we can do it here. But for scheduling consecutive captures,
//we calculate the time of the next capture every time based on the values given for captureEveryXFrames and renderingDeltaTime, in order to preserve accuracy.
perceptionCamera.startTime = perceptionCamera.startFrame * perceptionCamera.renderingDeltaTime;
var interval = perceptionCamera.framesBetweenCaptures * (perceptionCamera.renderingDeltaTime + 1);
EditorGUILayout.HelpBox($"First capture at {perceptionCamera.startTime} seconds and consecutive captures every {interval} seconds", MessageType.None);
}
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.renderingDeltaTime)),new GUIContent(frametimeTitle, ""));
EditorGUILayout.HelpBox($"Captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}", MessageType.None);
if (perceptionCamera.onlyRenderCapturedFrames)
{
}
else
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.renderingDeltaTime)),new GUIContent("Rendering Frame Time", ""));
}
serializedObject.ApplyModifiedProperties();

4
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 period, float firstCaptureTime, PerceptionCamera.CaptureTriggerMode captureTriggerMode, bool onlyRenderCapturedFrames, float renderingDeltaTime = -1)
public static SensorHandle RegisterSensor(EgoHandle egoHandle, string modality, string description, float period, float firstCaptureTime, PerceptionCamera.CaptureTriggerMode captureTriggerMode, bool onlyRenderCapturedFrames, float renderingDeltaTime = -1, int framesBetweenCaptures = 0)
SimulationState.AddSensor(egoHandle, modality, description, period, firstCaptureTime, captureTriggerMode, onlyRenderCapturedFrames, renderingDeltaTime, sensor);
SimulationState.AddSensor(egoHandle, modality, description, period, firstCaptureTime, captureTriggerMode, onlyRenderCapturedFrames, renderingDeltaTime, framesBetweenCaptures, sensor);
return sensor;
}

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


/// </summary>
public Camera attachedCamera => m_AttachedCamera;
/// <summary>
/// Frame number at which this camera starts capturing.
/// </summary>
public int startFrame;
/// <summary>
/// The method of triggering captures for this camera. In <see cref="PerceptionCamera.CaptureTriggerMode.Scheduled"/> mode, captures happen automatically based on a start time/frame and time/frame interval. In <see cref="PerceptionCamera.CaptureTriggerMode.Scheduled"/> mode, captures should be triggered manually through calling the <see cref="PerceptionCamera.CaptureOnNextUpdate"/> method of <see cref="PerceptionCamera"/>."
/// </summary>
public CaptureTriggerMode captureTriggerMode;
public CaptureTriggerMode captureTriggerMode = CaptureTriggerMode.Scheduled;
public bool onlyRenderCapturedFrames;
/// <summary>
/// When enabled, the camera will only render those frames that it needs to capture. In addition, the global frame delta time (<see cref="Time.captureDeltaTime"/>) will be altered to match this camera's capture period, thus, the scene will not be visually updated in-between captures (physics simulation is unaffected). If there is more than one <see cref="PerceptionCamera"/> active, this flag should be either disabled or enabled for all of them, otherwise the cameras will not capture and synchronize properly.
/// </summary>
public bool onlyRenderCapturedFrames = true;
/// <summary>
/// The rendering frame time (seconds). E.g. 0.0166 translates to 60 frames per second.
/// </summary>
/// <summary>
/// "The number of frames to render between the camera's scheduled captures when the rendering delta time is not controlled by this camera (i.e. <see cref="onlyRenderCapturedFrames"/> is false). Setting this to 0 makes the camera capture every rendered frame.
/// </summary>
public int framesBetweenCaptures = 0;
/// <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()
{
if (captureTriggerMode.Equals(CaptureTriggerMode.Manual))
{
SensorHandle.CaptureOnNextUpdate();
}
else
{
Debug.LogError($"{nameof(CaptureOnNextUpdate)} can only be used if the camera is in {nameof(CaptureTriggerMode.Manual)} capture mode.");
}
}
/// <summary>
/// Event invoked after the camera finishes rendering during a frame.

{
m_EgoMarker = GetComponentInParent<Ego>();
var ego = m_EgoMarker == null ? DatasetCapture.RegisterEgo("") : m_EgoMarker.EgoHandle;
SensorHandle = DatasetCapture.RegisterSensor(ego, "camera", description, period, startTime, captureTriggerMode, onlyRenderCapturedFrames, renderingDeltaTime);
SensorHandle = DatasetCapture.RegisterSensor(ego, "camera", description, period, startTime, captureTriggerMode, onlyRenderCapturedFrames, renderingDeltaTime, framesBetweenCaptures);
}
}

return;
#endif
CaptureRgbData(cam);
Debug.Log("===================== CAPTURING");
//Debug.Log("===================== CAPTURING");
foreach (var labeler in m_Labelers)
{

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


public PerceptionCamera.CaptureTriggerMode captureTriggerMode;
public bool onlyRenderCapturedFrames;
public float renderingDeltaTime;
public int captureEveryXFrames;
public bool externalCaptureRequestPending;
public float sequenceTimeOfNextCapture;

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

captureTriggerMode = captureTriggerMode,
onlyRenderCapturedFrames = controlSimulationTiming,
renderingDeltaTime = renderingDeltaTime,
captureEveryXFrames = captureEveryXFrames,
egoHandle = egoHandle,
lastCaptureFrameCount = -1
};

if (!activeSensor.ShouldCaptureThisFrame)
continue;
// TODO: AISV-845 This is an errant modification of this record that can lead to undefined behavior
// Leaving as-is for now because too many components depend on this logic
sensorData.sequenceTimeOfNextCapture += sensorData.period;
if (sensorData.onlyRenderCapturedFrames)
{
//In this case, the simulation timing is controlled by this and other sensors that have this flag enabled, so we can precisely jump to the next frame using a specific delta (capture period) provided by the user
sensorData.sequenceTimeOfNextCapture += sensorData.period;
}
else
{
//In this case, the sensor is scheduled but does not affect simulation timings, so it has to capture on specific rendered frames.
sensorData.sequenceTimeOfNextCapture += sensorData.renderingDeltaTime * sensorData.captureEveryXFrames;
}
//Debug.Log($"unscaled : {UnscaledSequenceTime}, seqNext {sensorData.sequenceTimeOfNextCapture}");
Debug.Assert(!sensorData.onlyRenderCapturedFrames || sensorData.sequenceTimeOfNextCapture > UnscaledSequenceTime,
$"Next scheduled capture should be after {UnscaledSequenceTime} but is {sensorData.sequenceTimeOfNextCapture}");

{
var thisSensorNextFrameDt = sensorData.renderingDeltaTime;
if (thisSensorNextFrameDt > 0f && thisSensorNextFrameDt < nextFrameDt)
if (thisSensorNextFrameDt < nextFrameDt)
nextFrameDt = thisSensorNextFrameDt;
}
}

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.1f, 0, true, true);
var sensor = DatasetCapture.RegisterSensor(ego, "camera", "", 0.1f, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
sensor.ReportCapture("file.txt", new SensorSpatialData());
expectedDatasetPath = DatasetCapture.OutputDirectory;
yield return new ExitPlayMode();

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


var ego = DatasetCapture.RegisterEgo("ego");
var firstCaptureTime = 1.5f;
var period = .4f;
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", period, firstCaptureTime, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", period, firstCaptureTime, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
float[] sequenceTimesExpected =
{

var ego = DatasetCapture.RegisterEgo("ego");
var firstCaptureTime = 1.5f;
var period = .4f;
DatasetCapture.RegisterSensor(ego, "cam", "", period, firstCaptureTime, true, true);
DatasetCapture.RegisterSensor(ego, "cam", "", period, firstCaptureTime, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
float[] deltaTimeSamplesExpected =
{

var timeScale = 2;
Time.timeScale = timeScale;
DatasetCapture.RegisterSensor(ego, "cam", "", period, firstCaptureTime, true, true);
DatasetCapture.RegisterSensor(ego, "cam", "", period, firstCaptureTime, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
float[] deltaTimeSamplesExpected =
{

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

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

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

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

var ego = DatasetCapture.RegisterEgo("ego");
var firstCaptureTime1 = 10;
var frequencyInMs1 = 4;
var sensor1 = DatasetCapture.RegisterSensor(ego, "cam", "1", frequencyInMs1, firstCaptureTime1, true, true);
var sensor1 = DatasetCapture.RegisterSensor(ego, "cam", "1", frequencyInMs1, firstCaptureTime1, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
var sensor2 = DatasetCapture.RegisterSensor(ego, "cam", "2", frequencyInMs2, firstCaptureTime2, true, true);
var sensor2 = DatasetCapture.RegisterSensor(ego, "cam", "2", frequencyInMs2, firstCaptureTime2, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
var sensor3 = DatasetCapture.RegisterSensor(ego, "cam", "3", 1, 1, true, true);
var sensor3 = DatasetCapture.RegisterSensor(ego, "cam", "3", 1, 1, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
sensor3.Enabled = false;
(float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture)[] samplesExpected =

[Test]
public void Enabled_StartsTrue()
{
var sensor1 = DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "cam", "1", 1, 1, true, true);
var sensor1 = DatasetCapture.RegisterSensor(DatasetCapture.RegisterEgo(""), "cam", "1", 1, 1, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
Assert.IsTrue(sensor1.Enabled);
}
}

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


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

}}";
var ego = DatasetCapture.RegisterEgo("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "camera", "", 1, 0, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "camera", "", 1, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
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, "", "", 2, 0, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 2, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
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, "", "", 1, 0, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
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, "", "", 1, 0, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
sensorHandle.ReportAnnotationValues(annotationDefinition, values);
DatasetCapture.ResetSimulation();

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

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

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

var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
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, "", "", 1, 0, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
var asyncAnnotation = sensorHandle.ReportAnnotationAsync(annotationDefinition);
Assert.IsTrue(asyncAnnotation.IsValid);

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

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

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

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

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

var ego = DatasetCapture.RegisterEgo("");
var metricDefinition = DatasetCapture.RegisterMetricDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
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, "", "", 1, 0, true, true);
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0, PerceptionCamera.CaptureTriggerMode.Scheduled, true);
var asyncMetric = sensorHandle.ReportMetricAsync(metricDefinition);
Assert.IsTrue(asyncMetric.IsValid);

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

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

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

正在加载...
取消
保存