Wesley Mareovich Smith
5 年前
当前提交
47d9ea99
共有 54 个文件被更改,包括 837 次插入 和 831 次删除
-
4TestProjects/PerceptionHDRP/Assets/Rotator.cs
-
1TestProjects/PerceptionHDRP/Packages/manifest.json
-
4TestProjects/PerceptionURP/Assets/Rotator.cs
-
1TestProjects/PerceptionURP/Packages/manifest.json
-
8com.unity.perception/Editor/GroundTruth/BaseCustomPassDrawer.cs
-
9com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs
-
109com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs
-
75com.unity.perception/Editor/GroundTruth/LabelingEditor.cs
-
7com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs
-
9com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs
-
5com.unity.perception/Runtime/GroundTruth/BoundingBoxOrigin.cs
-
6com.unity.perception/Runtime/GroundTruth/DatasetJsonUtility.cs
-
158com.unity.perception/Runtime/GroundTruth/GroundTruthCrossPipelinePass.cs
-
10com.unity.perception/Runtime/GroundTruth/GroundTruthInfo.cs
-
32com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs
-
3com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs
-
91com.unity.perception/Runtime/GroundTruth/GroundTruthRendererFeature.cs
-
19com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs
-
111com.unity.perception/Runtime/GroundTruth/InstanceSegmentationCrossPipelinePass.cs
-
9com.unity.perception/Runtime/GroundTruth/InstanceSegmentationPass.cs
-
41com.unity.perception/Runtime/GroundTruth/Labeling/Labeling.cs
-
35com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs
-
33com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs
-
112com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
-
21com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs
-
24com.unity.perception/Runtime/GroundTruth/RenderedObjectInfo.cs
-
14com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs
-
8com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs
-
4com.unity.perception/Runtime/GroundTruth/SemanticSegmentationPass.cs
-
4com.unity.perception/Runtime/GroundTruth/SimulationManagementComponentSystem.cs
-
114com.unity.perception/Runtime/GroundTruth/SimulationManager.cs
-
25com.unity.perception/Runtime/GroundTruth/SimulationState.cs
-
14com.unity.perception/Runtime/GroundTruth/SimulationState_Json.cs
-
66com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs
-
15com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs
-
11com.unity.perception/Tests/Runtime/GroundTruthTests/BoundingBox2DTests.cs
-
4com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetJsonUtilityTests.cs
-
15com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs
-
43com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs
-
9com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs
-
24com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs
-
32com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerTests.cs
-
7com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs
-
33com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs
-
74.editorconfig
-
38com.unity.perception/Runtime/GroundTruth/Ego.cs
-
31com.unity.perception/Runtime/GroundTruth/EgoMarker.cs
-
135com.unity.perception/Runtime/GroundTruth/MetricData.cs
-
11com.unity.perception/Runtime/GroundTruth/MetricData.cs.meta
-
0/com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs.meta
-
0/com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs
-
0/com.unity.perception/Runtime/GroundTruth/Ego.cs.meta
-
0/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs.meta
-
0/com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerSensorSchedulingTests.cs
|
|||
using UnityEditor; |
|||
using UnityEngine.Perception.Sensors; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
[CustomEditor(typeof(LabelingConfiguration))] |
|||
public class LabelingConfigurationEditor : Editor |
|||
namespace UnityEditor.Perception.GroundTruth |
|||
ReorderableList m_LabelsList; |
|||
|
|||
public void OnEnable() |
|||
[CustomEditor(typeof(LabelingConfiguration))] |
|||
class LabelingConfigurationEditor : Editor |
|||
m_LabelsList = new ReorderableList(this.serializedObject, this.serializedObject.FindProperty(nameof(LabelingConfiguration.LabelingConfigurations)), true, false, true, true); |
|||
m_LabelsList.elementHeight = EditorGUIUtility.singleLineHeight * 2; |
|||
m_LabelsList.drawElementCallback = DrawElement; |
|||
m_LabelsList.onAddCallback += OnAdd; |
|||
m_LabelsList.onRemoveCallback += OnRemove; |
|||
} |
|||
ReorderableList m_LabelsList; |
|||
void OnRemove(ReorderableList list) |
|||
{ |
|||
if (list.index != -1) |
|||
list.serializedProperty.DeleteArrayElementAtIndex(list.index); |
|||
public void OnEnable() |
|||
{ |
|||
m_LabelsList = new ReorderableList(this.serializedObject, this.serializedObject.FindProperty(nameof(LabelingConfiguration.LabelingConfigurations)), true, false, true, true); |
|||
m_LabelsList.elementHeight = EditorGUIUtility.singleLineHeight * 2; |
|||
m_LabelsList.drawElementCallback = DrawElement; |
|||
m_LabelsList.onAddCallback += OnAdd; |
|||
m_LabelsList.onRemoveCallback += OnRemove; |
|||
} |
|||
this.serializedObject.ApplyModifiedProperties(); |
|||
EditorUtility.SetDirty(target); |
|||
} |
|||
void OnRemove(ReorderableList list) |
|||
{ |
|||
if (list.index != -1) |
|||
list.serializedProperty.DeleteArrayElementAtIndex(list.index); |
|||
LabelingConfiguration config => (LabelingConfiguration)this.target; |
|||
this.serializedObject.ApplyModifiedProperties(); |
|||
EditorUtility.SetDirty(target); |
|||
} |
|||
void OnAdd(ReorderableList list) |
|||
{ |
|||
var index = list.serializedProperty.arraySize; |
|||
list.serializedProperty.InsertArrayElementAtIndex(index); |
|||
var element = list.serializedProperty.GetArrayElementAtIndex(index); |
|||
var labelProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.label)); |
|||
labelProperty.stringValue = ""; |
|||
var valueProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.value)); |
|||
valueProperty.intValue = 0; |
|||
serializedObject.ApplyModifiedProperties(); |
|||
EditorUtility.SetDirty(target); |
|||
} |
|||
void OnAdd(ReorderableList list) |
|||
{ |
|||
var index = list.serializedProperty.arraySize; |
|||
list.serializedProperty.InsertArrayElementAtIndex(index); |
|||
var element = list.serializedProperty.GetArrayElementAtIndex(index); |
|||
var labelProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.label)); |
|||
labelProperty.stringValue = ""; |
|||
var valueProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.value)); |
|||
valueProperty.intValue = 0; |
|||
serializedObject.ApplyModifiedProperties(); |
|||
EditorUtility.SetDirty(target); |
|||
} |
|||
void DrawElement(Rect rect, int index, bool isactive, bool isfocused) |
|||
{ |
|||
var element = m_LabelsList.serializedProperty.GetArrayElementAtIndex(index); |
|||
var labelProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.label)); |
|||
var valueProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.value)); |
|||
using (var change = new EditorGUI.ChangeCheckScope()) |
|||
void DrawElement(Rect rect, int index, bool isactive, bool isfocused) |
|||
var contentRect = new Rect(rect.position, new Vector2(rect.width, EditorGUIUtility.singleLineHeight)); |
|||
var newLabel = EditorGUI.TextField(contentRect, nameof(LabelingConfigurationEntry.label), labelProperty.stringValue); |
|||
if (change.changed) |
|||
labelProperty.stringValue = newLabel; |
|||
var element = m_LabelsList.serializedProperty.GetArrayElementAtIndex(index); |
|||
var labelProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.label)); |
|||
var valueProperty = element.FindPropertyRelative(nameof(LabelingConfigurationEntry.value)); |
|||
using (var change = new EditorGUI.ChangeCheckScope()) |
|||
{ |
|||
var contentRect = new Rect(rect.position, new Vector2(rect.width, EditorGUIUtility.singleLineHeight)); |
|||
var newLabel = EditorGUI.TextField(contentRect, nameof(LabelingConfigurationEntry.label), labelProperty.stringValue); |
|||
if (change.changed) |
|||
labelProperty.stringValue = newLabel; |
|||
} |
|||
|
|||
using (var change = new EditorGUI.ChangeCheckScope()) |
|||
{ |
|||
var contentRect = new Rect(rect.position + new Vector2(0, EditorGUIUtility.singleLineHeight), new Vector2(rect.width, EditorGUIUtility.singleLineHeight)); |
|||
var newValue = EditorGUI.IntField(contentRect, nameof(LabelingConfigurationEntry.value), valueProperty.intValue); |
|||
if (change.changed) |
|||
valueProperty.intValue = newValue; |
|||
} |
|||
using (var change = new EditorGUI.ChangeCheckScope()) |
|||
|
|||
public override void OnInspectorGUI() |
|||
var contentRect = new Rect(rect.position + new Vector2(0, EditorGUIUtility.singleLineHeight), new Vector2(rect.width, EditorGUIUtility.singleLineHeight)); |
|||
var newValue = EditorGUI.IntField(contentRect, nameof(LabelingConfigurationEntry.value), valueProperty.intValue); |
|||
if (change.changed) |
|||
valueProperty.intValue = newValue; |
|||
m_LabelsList.DoLayoutList(); |
|||
this.serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
m_LabelsList.DoLayoutList(); |
|||
this.serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
} |
|
|||
using UnityEditor; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
[CustomEditor(typeof(Labeling))] |
|||
public class LabelingEditor : Editor |
|||
namespace UnityEditor.Perception.GroundTruth |
|||
const int k_Indent = 7; |
|||
ReorderableList m_LabelsList; |
|||
|
|||
public void OnEnable() |
|||
[CustomEditor(typeof(Labeling))] |
|||
class LabelingEditor : Editor |
|||
m_LabelsList = new ReorderableList(this.serializedObject, this.serializedObject.FindProperty(nameof(Labeling.classes)), true, false, true, true); |
|||
m_LabelsList.drawElementCallback = DrawElement; |
|||
m_LabelsList.onAddCallback += OnAdd; |
|||
m_LabelsList.onRemoveCallback += OnRemove; |
|||
} |
|||
const int k_Indent = 7; |
|||
ReorderableList m_LabelsList; |
|||
void OnRemove(ReorderableList list) |
|||
{ |
|||
if (list.index != -1) |
|||
labeling.classes.RemoveAt(list.index); |
|||
} |
|||
public void OnEnable() |
|||
{ |
|||
m_LabelsList = new ReorderableList(serializedObject, serializedObject.FindProperty(nameof(global::UnityEngine.Perception.GroundTruth.Labeling.labels)), true, false, true, true); |
|||
m_LabelsList.drawElementCallback = DrawElement; |
|||
m_LabelsList.onAddCallback += OnAdd; |
|||
m_LabelsList.onRemoveCallback += OnRemove; |
|||
} |
|||
Labeling labeling => (Labeling)this.target; |
|||
void OnRemove(ReorderableList list) |
|||
{ |
|||
if (list.index != -1) |
|||
Labeling.labels.RemoveAt(list.index); |
|||
} |
|||
void OnAdd(ReorderableList list) |
|||
{ |
|||
labeling.classes.Add(""); |
|||
} |
|||
Labeling Labeling => (Labeling)target; |
|||
void DrawElement(Rect rect, int index, bool isactive, bool isfocused) |
|||
{ |
|||
using (var change = new EditorGUI.ChangeCheckScope()) |
|||
void OnAdd(ReorderableList list) |
|||
var indent = k_Indent * index; |
|||
if (indent >= rect.width) |
|||
return; |
|||
Labeling.labels.Add(""); |
|||
} |
|||
var contentRect = new Rect(rect.x + indent, rect.y, rect.width - indent, rect.height); |
|||
var value = EditorGUI.TextField(contentRect, labeling.classes[index]); |
|||
if (change.changed) |
|||
void DrawElement(Rect rect, int index, bool isactive, bool isfocused) |
|||
{ |
|||
using (var change = new EditorGUI.ChangeCheckScope()) |
|||
labeling.classes[index] = value; |
|||
var indent = k_Indent * index; |
|||
if (indent >= rect.width) |
|||
return; |
|||
|
|||
var contentRect = new Rect(rect.x + indent, rect.y, rect.width - indent, rect.height); |
|||
var value = EditorGUI.TextField(contentRect, Labeling.labels[index]); |
|||
if (change.changed) |
|||
{ |
|||
Labeling.labels[index] = value; |
|||
} |
|||
} |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
m_LabelsList.DoLayoutList(); |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
m_LabelsList.DoLayoutList(); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System; |
|||
using UnityEngine.Perception.Sensors; |
|||
public abstract class GroundTruthCrossPipelinePass : IGroundTruthGenerator |
|||
namespace UnityEngine.Perception.GroundTruth |
|||
public Camera targetCamera; |
|||
|
|||
bool m_IsActivated; |
|||
|
|||
protected GroundTruthCrossPipelinePass(Camera targetCamera) |
|||
abstract class GroundTruthCrossPipelinePass : IGroundTruthGenerator |
|||
this.targetCamera = targetCamera; |
|||
} |
|||
public Camera targetCamera; |
|||
public virtual void Setup() |
|||
{ |
|||
if (targetCamera == null) |
|||
throw new InvalidOperationException("targetCamera may not be null"); |
|||
bool m_IsActivated; |
|||
// If we are forced to activate here we will get zeroes in the first frame.
|
|||
EnsureActivated(); |
|||
} |
|||
protected GroundTruthCrossPipelinePass(Camera targetCamera) |
|||
{ |
|||
this.targetCamera = targetCamera; |
|||
} |
|||
public void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, Camera camera, CullingResults cullingResult) |
|||
{ |
|||
// CustomPasses are executed for each camera. We only want to run for the target camera
|
|||
if (camera != targetCamera) |
|||
return; |
|||
public virtual void Setup() |
|||
{ |
|||
if (targetCamera == null) |
|||
throw new InvalidOperationException("targetCamera may not be null"); |
|||
ExecutePass(renderContext, cmd, camera, cullingResult); |
|||
} |
|||
// If we are forced to activate here we will get zeroes in the first frame.
|
|||
EnsureActivated(); |
|||
} |
|||
protected abstract void ExecutePass(ScriptableRenderContext renderContext, CommandBuffer cmd, Camera camera, CullingResults cullingResult); |
|||
|
|||
public void EnsureActivated() |
|||
{ |
|||
if (!m_IsActivated) |
|||
public void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, Camera camera, CullingResults cullingResult) |
|||
var labelSetupSystem = World.DefaultGameObjectInjectionWorld?.GetExistingSystem<GroundTruthLabelSetupSystem>(); |
|||
labelSetupSystem?.Activate(this); |
|||
m_IsActivated = true; |
|||
// CustomPasses are executed for each camera. We only want to run for the target camera
|
|||
if (camera != targetCamera) |
|||
return; |
|||
|
|||
ExecutePass(renderContext, cmd, camera, cullingResult); |
|||
} |
|||
public void Cleanup() |
|||
{ |
|||
var labelSetupSystem = World.DefaultGameObjectInjectionWorld?.GetExistingSystem<GroundTruthLabelSetupSystem>(); |
|||
labelSetupSystem?.Deactivate(this); |
|||
} |
|||
protected abstract void ExecutePass(ScriptableRenderContext renderContext, CommandBuffer cmd, Camera camera, CullingResults cullingResult); |
|||
|
|||
protected RendererListDesc CreateRendererListDesc(Camera camera, CullingResults cullingResult, string overrideMaterialPassName, int overrideMaterialPassIndex, Material overrideMaterial, LayerMask layerMask/*, PerObjectData perObjectData*/) |
|||
{ |
|||
var shaderPasses = new[] |
|||
public void EnsureActivated() |
|||
new ShaderTagId("Forward"), // HD Lit shader
|
|||
new ShaderTagId("ForwardOnly"), // HD Unlit shader
|
|||
new ShaderTagId("SRPDefaultUnlit"), // Cross SRP Unlit shader
|
|||
new ShaderTagId("UniversalForward"), // URP Forward
|
|||
new ShaderTagId("LightweightForward"), // LWRP Forward
|
|||
new ShaderTagId(overrideMaterialPassName), // The override material shader
|
|||
}; |
|||
if (!m_IsActivated) |
|||
{ |
|||
var labelSetupSystem = World.DefaultGameObjectInjectionWorld?.GetExistingSystem<GroundTruthLabelSetupSystem>(); |
|||
labelSetupSystem?.Activate(this); |
|||
m_IsActivated = true; |
|||
} |
|||
} |
|||
var stateBlock = new RenderStateBlock(0) |
|||
public void Cleanup() |
|||
depthState = new DepthState(true, CompareFunction.LessEqual), |
|||
}; |
|||
var labelSetupSystem = World.DefaultGameObjectInjectionWorld?.GetExistingSystem<GroundTruthLabelSetupSystem>(); |
|||
labelSetupSystem?.Deactivate(this); |
|||
} |
|||
var result = new RendererListDesc(shaderPasses, cullingResult, camera) |
|||
protected RendererListDesc CreateRendererListDesc(Camera camera, CullingResults cullingResult, string overrideMaterialPassName, int overrideMaterialPassIndex, Material overrideMaterial, LayerMask layerMask /*, PerObjectData perObjectData*/) |
|||
rendererConfiguration = PerObjectData.None, |
|||
renderQueueRange = new RenderQueueRange { lowerBound = 0, upperBound = 5000 }, |
|||
sortingCriteria = SortingCriteria.CommonOpaque, |
|||
excludeObjectMotionVectors = false, |
|||
overrideMaterial = overrideMaterial, |
|||
overrideMaterialPassIndex = overrideMaterialPassIndex, |
|||
stateBlock = stateBlock, |
|||
layerMask = layerMask, |
|||
}; |
|||
return result; |
|||
} |
|||
var shaderPasses = new[] |
|||
{ |
|||
new ShaderTagId("Forward"), // HD Lit shader
|
|||
new ShaderTagId("ForwardOnly"), // HD Unlit shader
|
|||
new ShaderTagId("SRPDefaultUnlit"), // Cross SRP Unlit shader
|
|||
new ShaderTagId("UniversalForward"), // URP Forward
|
|||
new ShaderTagId("LightweightForward"), // LWRP Forward
|
|||
new ShaderTagId(overrideMaterialPassName), // The override material shader
|
|||
}; |
|||
var stateBlock = new RenderStateBlock(0) |
|||
{ |
|||
depthState = new DepthState(true, CompareFunction.LessEqual), |
|||
}; |
|||
public static void DrawRendererList(ScriptableRenderContext renderContext, CommandBuffer cmd, RendererList rendererList) |
|||
{ |
|||
if (!rendererList.isValid) |
|||
throw new ArgumentException("Invalid renderer list provided to DrawRendererList"); |
|||
var result = new RendererListDesc(shaderPasses, cullingResult, camera) |
|||
{ |
|||
rendererConfiguration = PerObjectData.None, |
|||
renderQueueRange = new RenderQueueRange { lowerBound = 0, upperBound = 5000 }, |
|||
sortingCriteria = SortingCriteria.CommonOpaque, |
|||
excludeObjectMotionVectors = false, |
|||
overrideMaterial = overrideMaterial, |
|||
overrideMaterialPassIndex = overrideMaterialPassIndex, |
|||
stateBlock = stateBlock, |
|||
layerMask = layerMask, |
|||
}; |
|||
return result; |
|||
} |
|||
// This is done here because DrawRenderers API lives outside command buffers so we need to make call this before doing any DrawRenders or things will be executed out of order
|
|||
renderContext.ExecuteCommandBuffer(cmd); |
|||
cmd.Clear(); |
|||
public static void DrawRendererList(ScriptableRenderContext renderContext, CommandBuffer cmd, RendererList rendererList) |
|||
{ |
|||
if (!rendererList.isValid) |
|||
throw new ArgumentException("Invalid renderer list provided to DrawRendererList"); |
|||
|
|||
// This is done here because DrawRenderers API lives outside command buffers so we need to make call this before doing any DrawRenders or things will be executed out of order
|
|||
renderContext.ExecuteCommandBuffer(cmd); |
|||
cmd.Clear(); |
|||
if (rendererList.stateBlock == null) |
|||
renderContext.DrawRenderers(rendererList.cullingResult, ref rendererList.drawSettings, ref rendererList.filteringSettings); |
|||
else |
|||
{ |
|||
var renderStateBlock = rendererList.stateBlock.Value; |
|||
renderContext.DrawRenderers(rendererList.cullingResult, ref rendererList.drawSettings, ref rendererList.filteringSettings, ref renderStateBlock); |
|||
if (rendererList.stateBlock == null) |
|||
renderContext.DrawRenderers(rendererList.cullingResult, ref rendererList.drawSettings, ref rendererList.filteringSettings); |
|||
else |
|||
{ |
|||
var renderStateBlock = rendererList.stateBlock.Value; |
|||
renderContext.DrawRenderers(rendererList.cullingResult, ref rendererList.drawSettings, ref rendererList.filteringSettings, ref renderStateBlock); |
|||
} |
|||
} |
|||
public abstract void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId); |
|||
public abstract void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId); |
|||
} |
|||
} |
|
|||
using Unity.Entities; |
|||
using Unity.Entities; |
|||
namespace UnityEngine.Perception.Sensors |
|||
namespace UnityEngine.Perception.GroundTruth |
|||
/// <summary>
|
|||
/// Information regarding a Labeling instance. Generated by <see cref="GroundTruthLabelSetupSystem"/>
|
|||
/// </summary>
|
|||
/// <summary>
|
|||
/// The instanceId assigned to the <see cref="Labeling"/>
|
|||
/// </summary>
|
|||
public uint instanceId; |
|||
} |
|||
} |
|
|||
#if URP_PRESENT
|
|||
#if URP_PRESENT
|
|||
using System.Collections.Generic; |
|||
using UnityEngine.Perception; |
|||
using UnityEngine.Perception.Sensors; |
|||
class InstanceSegmentationUrpPass : ScriptableRenderPass |
|||
namespace UnityEngine.Perception.GroundTruth |
|||
InstanceSegmentationCrossPipelinePass m_InstanceSegmentationPass; |
|||
class InstanceSegmentationUrpPass : ScriptableRenderPass |
|||
{ |
|||
InstanceSegmentationCrossPipelinePass m_InstanceSegmentationPass; |
|||
|
|||
public InstanceSegmentationUrpPass(Camera camera, RenderTexture targetTexture) |
|||
{ |
|||
m_InstanceSegmentationPass = new InstanceSegmentationCrossPipelinePass(camera); |
|||
ConfigureTarget(targetTexture, targetTexture.depthBuffer); |
|||
m_InstanceSegmentationPass.Setup(); |
|||
} |
|||
public InstanceSegmentationUrpPass(Camera camera, RenderTexture targetTexture) |
|||
{ |
|||
m_InstanceSegmentationPass = new InstanceSegmentationCrossPipelinePass(camera); |
|||
ConfigureTarget(targetTexture, targetTexture.depthBuffer); |
|||
m_InstanceSegmentationPass.Setup(); |
|||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) |
|||
{ |
|||
var commandBuffer = CommandBufferPool.Get(nameof(InstanceSegmentationUrpPass)); |
|||
m_InstanceSegmentationPass.Execute(context, commandBuffer, renderingData.cameraData.camera, renderingData.cullResults); |
|||
CommandBufferPool.Release(commandBuffer); |
|||
} |
|||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) |
|||
class SemanticSegmentationUrpPass : ScriptableRenderPass |
|||
var commandBuffer = CommandBufferPool.Get(nameof(InstanceSegmentationUrpPass)); |
|||
m_InstanceSegmentationPass.Execute(context, commandBuffer, renderingData.cameraData.camera, renderingData.cullResults); |
|||
CommandBufferPool.Release(commandBuffer); |
|||
} |
|||
} |
|||
class SemanticSegmentationUrpPass : ScriptableRenderPass |
|||
{ |
|||
SemanticSegmentationCrossPipelinePass m_SemanticSegmentationCrossPipelinePass; |
|||
SemanticSegmentationCrossPipelinePass m_SemanticSegmentationCrossPipelinePass; |
|||
public SemanticSegmentationUrpPass(Camera camera, RenderTexture targetTexture, LabelingConfiguration labelingConfiguration) |
|||
{ |
|||
m_SemanticSegmentationCrossPipelinePass = new SemanticSegmentationCrossPipelinePass(camera, labelingConfiguration); |
|||
ConfigureTarget(targetTexture, targetTexture.depthBuffer); |
|||
m_SemanticSegmentationCrossPipelinePass.Setup(); |
|||
} |
|||
public SemanticSegmentationUrpPass(Camera camera, RenderTexture targetTexture, LabelingConfiguration labelingConfiguration) |
|||
{ |
|||
m_SemanticSegmentationCrossPipelinePass = new SemanticSegmentationCrossPipelinePass(camera, labelingConfiguration); |
|||
ConfigureTarget(targetTexture, targetTexture.depthBuffer); |
|||
m_SemanticSegmentationCrossPipelinePass.Setup(); |
|||
} |
|||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) |
|||
{ |
|||
var commandBuffer = CommandBufferPool.Get(nameof(SemanticSegmentationUrpPass)); |
|||
m_SemanticSegmentationCrossPipelinePass.Execute(context, commandBuffer, renderingData.cameraData.camera, renderingData.cullResults); |
|||
CommandBufferPool.Release(commandBuffer); |
|||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) |
|||
{ |
|||
var commandBuffer = CommandBufferPool.Get(nameof(SemanticSegmentationUrpPass)); |
|||
m_SemanticSegmentationCrossPipelinePass.Execute(context, commandBuffer, renderingData.cameraData.camera, renderingData.cullResults); |
|||
CommandBufferPool.Release(commandBuffer); |
|||
} |
|||
} |
|||
public class GroundTruthRendererFeature : ScriptableRendererFeature |
|||
{ |
|||
public override void Create() |
|||
public class GroundTruthRendererFeature : ScriptableRendererFeature |
|||
} |
|||
public override void Create() {} |
|||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) |
|||
{ |
|||
var cameraObject = renderingData.cameraData.camera.gameObject; |
|||
var perceptionCamera = cameraObject.GetComponent<PerceptionCamera>(); |
|||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) |
|||
{ |
|||
var cameraObject = renderingData.cameraData.camera.gameObject; |
|||
var perceptionCamera = cameraObject.GetComponent<PerceptionCamera>(); |
|||
if (perceptionCamera == null) |
|||
return; |
|||
if (perceptionCamera == null) |
|||
return; |
|||
if (!EditorApplication.isPlaying) |
|||
return; |
|||
if (!EditorApplication.isPlaying) |
|||
return; |
|||
renderer.EnqueuePass(perceptionCamera.instanceSegmentationUrpPass); |
|||
renderer.EnqueuePass(perceptionCamera.semanticSegmentationUrpPass); |
|||
renderer.EnqueuePass(perceptionCamera.instanceSegmentationUrpPass); |
|||
renderer.EnqueuePass(perceptionCamera.semanticSegmentationUrpPass); |
|||
} |
|||
} |
|||
} |
|||
#endif
|
|
|||
using UnityEngine; |
|||
using UnityEngine; |
|||
public interface IGroundTruthGenerator |
|||
namespace UnityEngine.Perception.GroundTruth |
|||
void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId); |
|||
/// <summary>
|
|||
/// Interface for setting up MeshRenderers for ground truth generation via <see cref="GroundTruthLabelSetupSystem"/>.
|
|||
/// </summary>
|
|||
public interface IGroundTruthGenerator |
|||
{ |
|||
/// <summary>
|
|||
/// Called by <see cref="GroundTruthLabelSetupSystem"/> when first registered or when a Labeling is created at runtime.
|
|||
/// </summary>
|
|||
/// <param name="mpb">The MaterialPropertyBlock for the given meshRenderer. Can be used to set properties for custom rendering.</param>
|
|||
/// <param name="meshRenderer">The MeshRenderer which exists under the given Labeling.</param>
|
|||
/// <param name="labeling">The Labeling component created</param>
|
|||
/// <param name="instanceId">The instanceId assigned to the given Labeling instance.</param>
|
|||
void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId); |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections; |
|||
using UnityEngine.Serialization; |
|||
/// <summary>
|
|||
/// Defines a set of classes associated with the object and its descendants. Classes can be overwritten
|
|||
/// </summary>
|
|||
public class Labeling : MonoBehaviour |
|||
namespace UnityEngine.Perception.GroundTruth |
|||
public List<string> classes = new List<string>(); |
|||
/// <summary>
|
|||
/// Defines a set of labels associated with the object and its descendants. A Labeling component will override any Labeling components on the object's ancestors.
|
|||
/// </summary>
|
|||
public class Labeling : MonoBehaviour |
|||
{ |
|||
/// <summary>
|
|||
/// The label names to associate with the GameObject.
|
|||
/// </summary>
|
|||
[FormerlySerializedAs("classes")] |
|||
public List<string> labels = new List<string>(); |
|||
Entity entity; |
|||
|
|||
// Start is called before the first frame update
|
|||
void Awake() |
|||
{ |
|||
entity = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity(); |
|||
World.DefaultGameObjectInjectionWorld.EntityManager.AddComponentObject(entity, this); |
|||
} |
|||
Entity m_Entity; |
|||
void Awake() |
|||
{ |
|||
m_Entity = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity(); |
|||
World.DefaultGameObjectInjectionWorld.EntityManager.AddComponentObject(m_Entity, this); |
|||
} |
|||
private void OnDestroy() |
|||
{ |
|||
if (World.DefaultGameObjectInjectionWorld != null) |
|||
World.DefaultGameObjectInjectionWorld.EntityManager.DestroyEntity(entity); |
|||
void OnDestroy() |
|||
{ |
|||
if (World.DefaultGameObjectInjectionWorld != null) |
|||
World.DefaultGameObjectInjectionWorld.EntityManager.DestroyEntity(m_Entity); |
|||
} |
|||
} |
|||
} |
|
|||
; see http://editorconfig.org/ for docs on this file |
|||
|
|||
root = true |
|||
|
|||
[*] |
|||
ignore_if_in_header = This code was generated by a tool|<auto-generated> |
|||
indent_style = space |
|||
indent_size = 4 |
|||
; uncomment to help with sharing files across os's (i.e. network share or through local vm) |
|||
#end_of_line = lf |
|||
; avoid a bom, which causes endless problems with naive text tooling |
|||
charset = utf-8 |
|||
trim_trailing_whitespace = true |
|||
insert_final_newline = true |
|||
; keeping auto-format enabled helps avoid merge hell for projects without CI-based format validation |
|||
#disable_auto_format = true |
|||
|
|||
[*.cs] |
|||
; uncomment to enable full formatting of c# files |
|||
formatters = generic, uncrustify |
|||
|
|||
[*.asmdef] |
|||
scrape_api = true |
|||
|
|||
[**/Tests/**.asmdef] |
|||
scrape_api = false |
|||
|
|||
[*.Tests.asmdef] |
|||
scrape_api = false |
|||
|
|||
[*.md] |
|||
indent_size = 2 |
|||
; trailing whitespace is unfortunately significant in markdown |
|||
trim_trailing_whitespace = false |
|||
; uncomment to enable basic formatting of markdown files |
|||
#formatters = generic |
|||
|
|||
[{Makefile,makefile}] |
|||
; tab characters are part of the Makefile format |
|||
indent_style = tab |
|||
|
|||
[*.asmdef] |
|||
indent_size = 4 |
|||
|
|||
[*.json] |
|||
indent_size = 2 |
|||
|
|||
[*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}] |
|||
end_of_line = crlf |
|||
|
|||
; this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited. |
|||
; the settings are meant to closely match what VS does to minimize unnecessary diffs. |
|||
[*.{vcxproj,vcxproj.filters}] |
|||
indent_style = space |
|||
indent_size = 2 |
|||
end_of_line = crlf |
|||
charset = utf-8-bom |
|||
trim_trailing_whitespace = true |
|||
insert_final_newline = false |
|||
; must be broken out because of 51-char bug (https://github.com/editorconfig/editorconfig-visualstudio/issues/21) |
|||
[*.{csproj,pyproj,props,targets}] |
|||
indent_style = space |
|||
indent_size = 2 |
|||
end_of_line = crlf |
|||
charset = utf-8-bom |
|||
trim_trailing_whitespace = true |
|||
insert_final_newline = false |
|||
[*.{sln,sln.template}] |
|||
indent_style = tab |
|||
indent_size = 4 |
|||
end_of_line = crlf |
|||
charset = utf-8 |
|||
trim_trailing_whitespace = true |
|||
insert_final_newline = false |
|
|||
using System; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEngine.Perception.GroundTruth |
|||
{ |
|||
/// <summary>
|
|||
/// Marker indicating the GameObject is the root of the ego for a set of sensors. Works with <see cref="PerceptionCamera"/>.
|
|||
/// Custom sensors can use the <see cref="EgoHandle"/> property to register themselves under this ego.
|
|||
/// </summary>
|
|||
public class Ego : MonoBehaviour |
|||
{ |
|||
/// <summary>
|
|||
/// A human-readable description for this Ego to be included in the dataset.
|
|||
/// </summary>
|
|||
public string Description; |
|||
EgoHandle m_EgoHandle; |
|||
|
|||
public EgoHandle EgoHandle |
|||
{ |
|||
get |
|||
{ |
|||
EnsureEgoInitialized(); |
|||
return m_EgoHandle; |
|||
} |
|||
} |
|||
|
|||
void Start() |
|||
{ |
|||
EnsureEgoInitialized(); |
|||
} |
|||
|
|||
void EnsureEgoInitialized() |
|||
{ |
|||
if (m_EgoHandle == default) |
|||
m_EgoHandle = SimulationManager.RegisterEgo(Description); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEngine.Perception |
|||
{ |
|||
public class EgoMarker : MonoBehaviour |
|||
{ |
|||
public string Description; |
|||
Ego m_Ego; |
|||
|
|||
public Ego Ego |
|||
{ |
|||
get |
|||
{ |
|||
EnsureEgoInitialized(); |
|||
return m_Ego; |
|||
} |
|||
} |
|||
|
|||
void Start() |
|||
{ |
|||
EnsureEgoInitialized(); |
|||
} |
|||
|
|||
void EnsureEgoInitialized() |
|||
{ |
|||
if (m_Ego == default) |
|||
m_Ego = SimulationManager.RegisterEgo(Description); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using USim = Unity.Simulation; |
|||
|
|||
namespace UnityEngine.Perception.Sensors |
|||
{ |
|||
class MetricData<T> |
|||
{ |
|||
public string Name; |
|||
public SimulationInfo SimulationInfo; |
|||
public CurrentContext CurrentContext; |
|||
public T Metric; |
|||
|
|||
public MetricData(string name, T metric) |
|||
{ |
|||
if(string.IsNullOrEmpty(name)) { |
|||
throw new ArgumentException("Arg name is null or empty"); |
|||
} |
|||
|
|||
this.Name = name; |
|||
this.Metric = metric; |
|||
this.SimulationInfo = SimulationInfo.GetInstance(); |
|||
this.CurrentContext = CurrentContext.NewCurrentContext(); |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
class SensorMetric |
|||
{ |
|||
public string SensorId; |
|||
public int FrameId; |
|||
public List<ObjectCountEntry> SegmentedHistogram = new List<ObjectCountEntry>(); |
|||
} |
|||
|
|||
[Serializable] |
|||
struct ObjectCountEntry |
|||
{ |
|||
public string Label; |
|||
public uint Count; |
|||
} |
|||
|
|||
[Serializable] |
|||
struct CurrentContext |
|||
{ |
|||
static USim.Manager s_Manager; |
|||
public double SimulationElapsedTime; |
|||
public double SimulationElapsedTimeUnscaled; |
|||
|
|||
public static CurrentContext NewCurrentContext() |
|||
{ |
|||
if(s_Manager == null) { |
|||
s_Manager = USim.Manager.Instance; |
|||
} |
|||
|
|||
return new CurrentContext() { |
|||
SimulationElapsedTime = s_Manager.SimulationElapsedTime, |
|||
SimulationElapsedTimeUnscaled = s_Manager.SimulationElapsedTimeUnscaled, |
|||
}; |
|||
} |
|||
} |
|||
|
|||
/// <summary> SimulationInfo - Context that is unchanged for this entire simulation </summary>
|
|||
[Serializable] |
|||
class SimulationInfo |
|||
{ |
|||
public string ProjectId; |
|||
public string RunId; |
|||
public string ExecutionId; |
|||
public string AppParamId; |
|||
public string RunInstanceId; |
|||
public string AttemptId; |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return string.Format("{0}/{1}/{2}/{3}/{4}/{5}", |
|||
this.ProjectId, |
|||
this.RunId, |
|||
this.ExecutionId, |
|||
this.AppParamId, |
|||
this.RunInstanceId, |
|||
this.AttemptId); |
|||
} |
|||
|
|||
static SimulationInfo s_Context; |
|||
|
|||
public static SimulationInfo GetInstance() |
|||
{ |
|||
if(s_Context != null) { |
|||
return s_Context; |
|||
} |
|||
|
|||
var config = USim.Configuration.Instance; |
|||
if(config.IsSimulationRunningInCloud()) { |
|||
s_Context = GetInstance(config.GetStoragePath()); |
|||
} else { |
|||
s_Context = new SimulationInfo() { |
|||
ProjectId = Guid.NewGuid().ToString(), |
|||
AppParamId = "urn:app_param_id:app_param_id", |
|||
ExecutionId = "urn:app_param_id:exn_id", |
|||
RunId = "urn:app_param_id:run_id", |
|||
RunInstanceId = "0", |
|||
AttemptId = "0" |
|||
}; |
|||
} |
|||
|
|||
return s_Context; |
|||
} |
|||
|
|||
static SimulationInfo GetInstance(string storagePath) |
|||
{ |
|||
if(string.IsNullOrEmpty(storagePath)) { |
|||
throw new ArgumentException("Arg storagePath is null or empty"); |
|||
} |
|||
|
|||
const int expectedTokenCount = 8; |
|||
var tokens = storagePath.Split('/'); |
|||
if (tokens.Length < expectedTokenCount) { |
|||
var msg = "Storage path not in the expected format"; |
|||
Debug.LogError(msg); |
|||
throw new ArgumentException(msg); |
|||
} |
|||
|
|||
return new SimulationInfo() |
|||
{ |
|||
ProjectId = tokens[1], |
|||
RunId = tokens[3], |
|||
ExecutionId = tokens[4], |
|||
AppParamId = tokens[5], |
|||
RunInstanceId = tokens[6], |
|||
AttemptId = tokens[7] |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 21e0b364c4d364d4a8d36cd1b2648bb0 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue