浏览代码

refinements

/manual_capture
Mohsen Kamalzadeh 4 年前
当前提交
98c3ff7e
共有 2 个文件被更改,包括 27 次插入25 次删除
  1. 16
      com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
  2. 36
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs

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


string onlyRenderCaptTitle = "Only Render Captured Frames";
string periodTilte = "Capture and Render Interval";
string frametimeTitle = "Rendering Frame Time";
string periodTilte = "Capture and Render Delta Time";
string frametimeTitle = "Rendering Delta Time";
int startFrame;
public override void OnInspectorGUI()
{

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);
EditorGUILayout.HelpBox($"First capture at {perceptionCamera.startTime} seconds and consecutive captures every {perceptionCamera.period} seconds of simulation time.", MessageType.None);
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.renderingDeltaTime)),new GUIContent(frametimeTitle, "The rendering delta time (seconds of simulation time). E.g. 0.0166 translates to roughly 60 frames per second. Note that if the hardware is not capable of rendering, capturing, and saving the required number of frames per second, the simulation will slow down in real time in order to produce the exact number of required frames per each second of simulation time. Thus, the results will always be correct with regard to simulation time but may look slow in real time."));
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."));

var interval = perceptionCamera.framesBetweenCaptures * (perceptionCamera.renderingDeltaTime + 1);
EditorGUILayout.HelpBox($"First capture at {perceptionCamera.startTime} seconds and consecutive captures every {interval} seconds", MessageType.None);
var interval = (perceptionCamera.framesBetweenCaptures + 1) * perceptionCamera.renderingDeltaTime;
EditorGUILayout.HelpBox($"First capture at {perceptionCamera.startTime} seconds and consecutive captures every {interval} seconds of simulation time.", MessageType.None);
}

{
perceptionCamera.onlyRenderCapturedFrames = false;
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);
EditorGUILayout.HelpBox($"Captures should be triggered manually through calling the {nameof(perceptionCamera.CaptureOnNextUpdate)} method of {nameof(PerceptionCamera)}. Framerate will not be modified by this camera.", MessageType.None);
//EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(PerceptionCamera.labelers)));
m_LabelersList.DoLayoutList();
}

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


foreach (var activeSensor in m_ActiveSensors)
{
var sensorData = m_Sensors[activeSensor];
if (sensorData.onlyRenderCapturedFrames)
if (sensorData.captureTriggerMode.Equals(PerceptionCamera.CaptureTriggerMode.Scheduled))
var thisSensorNextFrameDt = sensorData.sequenceTimeOfNextCapture - UnscaledSequenceTime;
//if the sensor is not scheduled, it does not need to force the simulation to produce frames at a specific rate, so we will not need to touch Time.captureDeltaTime.
if (sensorData.onlyRenderCapturedFrames)
{
var thisSensorNextFrameDt = sensorData.sequenceTimeOfNextCapture - UnscaledSequenceTime;
Debug.Assert(thisSensorNextFrameDt > 0f, "Sensor was scheduled to run in the past but got skipped over.");
if (thisSensorNextFrameDt > 0f && thisSensorNextFrameDt < nextFrameDt)
nextFrameDt = thisSensorNextFrameDt;
}
else
{
var thisSensorNextFrameDt = sensorData.renderingDeltaTime;
Debug.Assert(thisSensorNextFrameDt > 0f, "Sensor was scheduled to run in the past but got skipped over.");
if (thisSensorNextFrameDt > 0f && thisSensorNextFrameDt < nextFrameDt)
nextFrameDt = thisSensorNextFrameDt;
}
else
{
var thisSensorNextFrameDt = sensorData.renderingDeltaTime;
if (thisSensorNextFrameDt < nextFrameDt)
nextFrameDt = thisSensorNextFrameDt;
if (thisSensorNextFrameDt > 0f && thisSensorNextFrameDt < nextFrameDt)
nextFrameDt = thisSensorNextFrameDt;
}
// if (Math.Abs(nextFrameDt - k_MaxDeltaTime) < 0.00001)
// {
// //means no sensor is controlling simulation timing, default to 60fps
// nextFrameDt = 1f/60;
// }
if (Math.Abs(nextFrameDt - k_MaxDeltaTime) < 0.00001)
{
//means no sensor is controlling simulation timing, so we set Time.captureDeltaTime to 0 (default) to render normally
nextFrameDt = 0;
}
WritePendingCaptures();
WritePendingMetrics();

正在加载...
取消
保存