浏览代码

Further docs and naming

/main
Jon Hogins 5 年前
当前提交
0139bd5b
共有 20 个文件被更改,包括 160 次插入79 次删除
  1. 1
      TestProjects/PerceptionHDRP/Packages/manifest.json
  2. 6
      com.unity.perception/Editor/GroundTruth/BaseCustomPassDrawer.cs
  3. 6
      com.unity.perception/Editor/GroundTruth/InstanceSegmentationPassEditor.cs
  4. 10
      com.unity.perception/Editor/GroundTruth/LabelingEditor.cs
  5. 1
      com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs
  6. 1
      com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs
  7. 2
      com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs
  8. 7
      com.unity.perception/Runtime/GroundTruth/InstanceSegmentationPass.cs
  9. 8
      com.unity.perception/Runtime/GroundTruth/Labeling/Labeling.cs
  10. 31
      com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs
  11. 29
      com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs
  12. 17
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  13. 15
      com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs
  14. 21
      com.unity.perception/Runtime/GroundTruth/RenderedObjectInfo.cs
  15. 2
      com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs
  16. 2
      com.unity.perception/Runtime/GroundTruth/SemanticSegmentationPass.cs
  17. 60
      com.unity.perception/Runtime/GroundTruth/SimulationManager.cs
  18. 5
      com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs
  19. 13
      com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs
  20. 2
      com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs

1
TestProjects/PerceptionHDRP/Packages/manifest.json


"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.1.4",
"com.unity.package-validation-suite": "0.9.1-preview",
"com.unity.perception": "file:../../../com.unity.perception",
"com.unity.render-pipelines.core": "7.3.1",
"com.unity.render-pipelines.high-definition": "7.3.1",

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


using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace UnityEngine.Perception.Sensors.Editor
namespace UnityEditor.Perception.GroundTruth
{
public class BaseCustomPassDrawer : CustomPassDrawer
{

}
}
}
#endif
#endif

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


using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
using UnityEngine.Perception.GroundTruth;
namespace UnityEngine.Perception.Sensors.Editor
namespace UnityEditor.Perception.GroundTruth
{
[CustomPassDrawer(typeof(InstanceSegmentationPass))]
public class InstanceSegmentationPassEditor : BaseCustomPassDrawer

var targetCameraProperty = customPass.FindPropertyRelative(nameof(GroundTruthPass.targetCamera));
AddProperty(targetCameraProperty);
AddProperty(customPass.FindPropertyRelative(nameof(InstanceSegmentationPass.targetTexture)));
AddProperty(customPass.FindPropertyRelative(nameof(InstanceSegmentationPass.reassignIds)));
AddProperty(customPass.FindPropertyRelative(nameof(InstanceSegmentationPass.idStart)));
AddProperty(customPass.FindPropertyRelative(nameof(InstanceSegmentationPass.idStep)));
base.Initialize(customPass);
}
}

10
com.unity.perception/Editor/GroundTruth/LabelingEditor.cs


public void OnEnable()
{
m_LabelsList = new ReorderableList(serializedObject, serializedObject.FindProperty(nameof(global::Labeling.classes)), true, false, true, true);
m_LabelsList = new ReorderableList(serializedObject, serializedObject.FindProperty(nameof(global::Labeling.labels)), true, false, true, true);
m_LabelsList.drawElementCallback = DrawElement;
m_LabelsList.onAddCallback += OnAdd;
m_LabelsList.onRemoveCallback += OnRemove;

{
if (list.index != -1)
Labeling.classes.RemoveAt(list.index);
Labeling.labels.RemoveAt(list.index);
}
Labeling Labeling => (Labeling)target;

Labeling.classes.Add("");
Labeling.labels.Add("");
}
void DrawElement(Rect rect, int index, bool isactive, bool isfocused)

return;
var contentRect = new Rect(rect.x + indent, rect.y, rect.width - indent, rect.height);
var value = EditorGUI.TextField(contentRect, Labeling.classes[index]);
var value = EditorGUI.TextField(contentRect, Labeling.labels[index]);
Labeling.classes[index] = value;
Labeling.labels[index] = value;
}
}
}

1
com.unity.perception/Editor/GroundTruth/ObjectCountPassEditor.cs


using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
using UnityEngine.Perception.GroundTruth;
namespace UnityEditor.Perception.GroundTruth
{

1
com.unity.perception/Editor/GroundTruth/SemanticSegmentationPassEditor.cs


using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Rendering.HighDefinition;
using UnityEngine.Perception.GroundTruth;
namespace UnityEditor.Perception.GroundTruth
{

2
com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs


using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
namespace UnityEngine.Perception.Sensors
namespace UnityEngine.Perception.GroundTruth
{
public abstract class GroundTruthPass : CustomPass, IGroundTruthGenerator
{

7
com.unity.perception/Runtime/GroundTruth/InstanceSegmentationPass.cs


using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Rendering;
namespace UnityEngine.Perception.Sensors
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// A CustomPass for creating object instance segmentation images. GameObjects containing Labeling components

InstanceSegmentationCrossPipelinePass m_InstanceSegmentationCrossPipelinePass;
public RenderTexture targetTexture;
public bool reassignIds = false;
public uint idStart = 1;
public uint idStep = 1;
public Camera targetCamera;
[UsedImplicitly]

{
if (m_InstanceSegmentationCrossPipelinePass == null)
{
m_InstanceSegmentationCrossPipelinePass = new InstanceSegmentationCrossPipelinePass(targetCamera, idStart, idStep);
m_InstanceSegmentationCrossPipelinePass = new InstanceSegmentationCrossPipelinePass(targetCamera);
m_InstanceSegmentationCrossPipelinePass.Setup();
}
}

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


using System.Collections.Generic;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Serialization;
/// Defines a set of classes associated with the object and its descendants. Classes can be overwritten
/// 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.
/// The class names to associate with the GameObject.
/// The label names to associate with the GameObject.
public List<string> classes = new List<string>();
[FormerlySerializedAs("classes")]
public List<string> labels = new List<string>();
Entity m_Entity;
void Awake()

31
com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs


namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// A definition for how a <see cref="Labeling"/> should be resolved to a single label and id for ground truth generation.
/// </summary>
/// <summary>
/// A sequence of <see cref="LabelingConfigurationEntry"/> which defines the labels relevant for this configuration and their values.
/// </summary>
/// <summary>
/// Attempts to find the matching index in <see cref="LabelingConfigurations"/> for the given <see cref="Labeling"/>.
/// </summary>
/// <remarks>
/// The matching index is the first class name in the given Labeling which matches an entry in <see cref="LabelingConfigurations"/>.
/// </remarks>
/// <param name="labeling">The <see cref="Labeling"/> to match </param>
/// <param name="index">When this method returns, contains the index of the matching <see cref="LabelingConfigurationEntry"/>, or -1 if no match was found.</param>
/// <returns>Returns true if a match was found. False if not.</returns>
foreach (var labelingClass in labeling.classes)
foreach (var labelingClass in labeling.labels)
{
for (var i = 0; i < LabelingConfigurations.Count; i++)
{

}
}
/// <summary>
/// Structure defining a label configuration for <see cref="LabelingConfiguration"/>.
/// </summary>
/// <summary>
/// The label string
/// </summary>
/// <summary>
/// The value to use when generating semantic segmentation images.
/// </summary>
/// <summary>
/// Creates a new LabelingConfigurationEntry with the given values.
/// </summary>
/// <param name="label">The label string.</param>
/// <param name="value">The value to use when generating semantic segmentation images.</param>
public LabelingConfigurationEntry(string label, int value)
{
this.label = label;

29
com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs


using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Rendering;
namespace UnityEngine.Perception.Sensors
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// CustomPass which computes object count for each label in the given LabelingConfiguration in the frame.

{
}
public bool WriteToLog { get; set; }
public override void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId)
{
if (!m_InstanceIdToClassIdLookup.IsCreated)

var objectCount = k_StartingObjectCount;
UpdateIdBufferSizes(objectCount);
m_ClassCounts = new ComputeBuffer(LabelingConfiguration.LabelingConfigurations.Count + 1, UnsafeUtility.SizeOf<uint>(), ComputeBufferType.Structured);
m_DataLogger = new Unity.Simulation.Logger("LabelHistogram");
RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
}

internal event Action<NativeSlice<uint>, IReadOnlyList<LabelingConfigurationEntry>, int> ClassCountsReceived;
Unity.Simulation.Logger m_DataLogger;
void OnClassCountReadback(int requestFrameCount, NativeArray<uint> counts)
{
#if PERCEPTION_DEBUG

}
Debug.Log(sb);
#endif
if (WriteToLog)
{
//This is a bad pattern. We need to be able to log a JSON string without tons of allocations
var sensorMetric = new SensorMetric() {
FrameId = Time.frameCount
};
var sensorMetricData = new MetricData<SensorMetric>(
"sensor_metric",
sensorMetric);
for (int i = 0; i < LabelingConfiguration.LabelingConfigurations.Count; i++)
{
sensorMetric.SegmentedHistogram.Add(new ObjectCountEntry
{
Label = LabelingConfiguration.LabelingConfigurations[i].label,
Count = counts[i + 1]
});
}
m_DataLogger.Log(sensorMetricData);
}
ClassCountsReceived?.Invoke(new NativeSlice<uint>(counts, 1), LabelingConfiguration.LabelingConfigurations, requestFrameCount);
}

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


#if HDRP_PRESENT
using UnityEngine.Rendering.HighDefinition;
#endif
using UnityEngine.Perception.Sensors;
using UnityEngine.Perception.GroundTruth;
namespace UnityEngine.Perception.GroundTruth
{

for (var i = 0; i < renderedObjectInfos.Length; i++)
{
var objectInfo = renderedObjectInfos[i];
if (!TryGetClassIdFromInstanceId(objectInfo.instanceId, out var labelId))
if (!TryGetLabelIdFromInstanceId(objectInfo.instanceId, out var labelId))
continue;
m_VisiblePixelsValues[i] = new VisiblePixelsValue

for (var i = 0; i < renderedObjectInfos.Length; i++)
{
var objectInfo = renderedObjectInfos[i];
if (!TryGetClassIdFromInstanceId(objectInfo.instanceId, out var labelId))
if (!TryGetLabelIdFromInstanceId(objectInfo.instanceId, out var labelId))
continue;
m_BoundingBoxValues[i] = new BoundingBoxValue

}
}
public bool TryGetClassIdFromInstanceId(int instanceId, out int labelId)
/// <summary>
/// Returns the class ID for the given instance ID resolved by <see cref="LabelingConfiguration"/>. Only valid when bounding boxes are being computed.
/// </summary>
/// <param name="instanceId">The instanceId of the object</param>
/// <param name="labelId">When this method returns, contains the labelId associated with the given instanceId, if one exists. -1 otherwise.</param>
/// <returns>True if a valid labelId was found for the given instanceId.</returns>
/// <exception cref="InvalidOperationException">Thrown when <see cref="produceBoundingBoxAnnotations"/> was not true on Start.</exception>
public bool TryGetLabelIdFromInstanceId(int instanceId, out int labelId)
throw new InvalidOperationException($"{nameof(TryGetClassIdFromInstanceId)} can only be used when bounding box capture is enabled");
throw new InvalidOperationException($"{nameof(TryGetLabelIdFromInstanceId)} can only be used when bounding box capture is enabled");
return m_RenderedObjectInfoGenerator.TryGetLabelIdFromInstanceId(instanceId, out labelId);
}

15
com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs


using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
namespace UnityEngine.Perception.Sensors
namespace UnityEngine.Perception.GroundTruth
/// <typeparam name="T">The type of the raw texture data to be provided.</typeparam>
public class RenderTextureReader<T> : IDisposable where T : struct
{
RenderTexture m_Source;

ProfilerMarker m_WaitingForCompletionMarker = new ProfilerMarker("RenderTextureReader_WaitingForCompletion");
/// <summary>
/// Creates a new <see cref="RenderTextureReader{T}"/> for the given <see cref="RenderTexture"/>, <see cref="Camera"/>, and image readback callback
/// </summary>
/// <param name="source">The <see cref="RenderTexture"/> to read from.</param>
/// <param name="cameraRenderingToSource">The <see cref="Camera"/> which renders to the given renderTexture. This is used to determine when to read from the texture.</param>
/// <param name="imageReadCallback">The callback to call after reading the texture</param>
public RenderTextureReader(RenderTexture source, Camera cameraRenderingToSource, Action<int, NativeArray<T>, RenderTexture> imageReadCallback)
{
this.m_Source = source;

}
}
/// <summary>
/// Synchronously wait for all image requests to complete.
/// </summary>
/// <summary>
/// Shut down the reader, waiting for all requests to return.
/// </summary>
public void Dispose()
{
WaitForAllImages();

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


using System;
namespace UnityEngine.Perception
namespace UnityEngine.Perception.GroundTruth
/// <summary>
/// Describes an instance of an object in an instance segmentation frame. Generated by <see cref="RenderedObjectInfoGenerator"/>.
/// </summary>
/// <summary>
/// The instanceId of the rendered object.
/// </summary>
/// <summary>
/// The labelId of the object resolved by a <see cref="LabelingConfiguration"/>
/// </summary>
/// <summary>
/// The bounding box of the object in pixel coordinates.
/// </summary>
/// <summary>
/// The number of pixels in the image matching this instance.
/// </summary>
/// <inheritdoc />
/// <inheritdoc />
/// <inheritdoc />
/// <inheritdoc />
public override int GetHashCode()
{
unchecked

2
com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs


var entry = new LabelingConfigurationEntry();
foreach (var l in m_LabelingConfiguration.LabelingConfigurations)
{
if (labeling.classes.Contains(l.label))
if (labeling.labels.Contains(l.label))
{
entry = l;
break;

2
com.unity.perception/Runtime/GroundTruth/SemanticSegmentationPass.cs


using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
namespace UnityEngine.Perception.Sensors
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// Custom Pass which renders labeled images where each object with a Labeling component is drawn with the value

60
com.unity.perception/Runtime/GroundTruth/SimulationManager.cs


/// </summary>
/// <param name="name">Human readable annotation spec name (e.g. sementic_segmentation, instance_segmentation, etc.)</param>
/// <param name="description">Description of the annotation.</param>
/// <param name="specValues">Format-specific specification for the metric values</param>
/// <param name="specValues">Format-specific specification for the metric values. Will be converted to json automatically.</param>
/// <typeparam name="TSpec">The type of the <see cref="specValues"/> struct to write.</typeparam>
/// <returns>A MetricDefinition, which can be used during this simulation to report metrics.</returns>
public static MetricDefinition RegisterMetricDefinition<TSpec>(string name, TSpec[] specValues, string description = null, Guid id = default)
{

/// </summary>
/// <param name="metricDefinition">The MetricDefinition associated with this metric. <see cref="RegisterMetricDefinition"/></param>
/// <param name="values">An array to be converted to json and put in the "values" field of the metric</param>
/// <typeparam name="T">The type of the <see cref="values"/> array</typeparam>
public static void ReportMetric<T>(MetricDefinition metricDefinition, T[] values)
{
SimulationState.ReportMetric(metricDefinition, values, default, default);

/// <summary>
/// Report a metric not associated with any sensor or annotation.
/// </summary>
/// <param name="metricDefinition"></param>
/// <param name="metricDefinition">The metric definition of the metric being reported</param>
public static AsyncMetric ReportMetricAsync(MetricDefinition metricDefinition) => SimulationState.CreateAsyncMetric(metricDefinition);
/// <summary>

/// Report a value-based annotation related to this sensor in this frame.
/// </summary>
/// <param name="annotationDefinition">The AnnotationDefinition of this annotation.</param>
/// <param name="values">The annotation data.</param>
/// <returns>A handle to the reported annotation for reporting annotation-based metrics.</returns>
/// <param name="values">The annotation data, which will be automatically converted to json.</param>
/// <typeparam name="T">The type of the values array.</typeparam>
/// <returns>Returns a handle to the reported annotation for reporting annotation-based metrics.</returns>
/// <exception cref="InvalidOperationException">Thrown if this method is called during a frame where <see cref="ShouldCaptureThisFrame"/> is false.</exception>
/// <exception cref="ArgumentException">Thrown if the given AnnotationDefinition is invalid.</exception>
public Annotation ReportAnnotationValues<T>(AnnotationDefinition annotationDefinition, T[] values)

/// <summary>
/// Creates an async annotation for reporting the values for an annotation during a future frame.
///
/// <returns>A handle to the <see cref="AsyncAnnotation"/>, which can be used to report annotation data during a subsequent frame.</returns>
/// <returns>Returns a handle to the <see cref="AsyncAnnotation"/>, which can be used to report annotation data during a subsequent frame.</returns>
/// <exception cref="InvalidOperationException">Thrown if this method is called during a frame where <see cref="ShouldCaptureThisFrame"/> is false.</exception>
/// <exception cref="ArgumentException">Thrown if the given AnnotationDefinition is invalid.</exception>
public AsyncAnnotation ReportAnnotationAsync(AnnotationDefinition annotationDefinition)

/// <summary>
/// Start an async metric for reporting metric values for this frame in a subsequent frame.
/// </summary>
/// <param name="metricDefinition">The <see cref="MetricDefinition"/> of the metric.</param>
/// <exception cref="InvalidOperationException">Thrown if <see cref="ShouldCaptureThisFrame"/> is false.</exception>
/// <param name="metricDefinition">The <see cref="MetricDefinition"/> of the metric</param>
/// <exception cref="InvalidOperationException">Thrown if <see cref="ShouldCaptureThisFrame"/> is false</exception>
/// <returns>An <see cref="AsyncMetric"/> which should be used to report the metric values, potentially in a later frame</returns>
public AsyncMetric ReportMetricAsync(MetricDefinition metricDefinition)
{
if (!ShouldCaptureThisFrame)

throw new InvalidOperationException("SensorHandle has been disposed or its simulation has ended");
}
/// <inheritdoc/>
/// <inheritdoc/>
/// <inheritdoc/>
/// <summary>
/// Compares two <see cref="SensorHandle"/> instances for equality.
/// </summary>
/// <param name="left">The first SensorHandle.</param>
/// <param name="right">The second SensorHandle.</param>
/// <returns>Returns true if the two SensorHandles refer to the same sensor.</returns>
/// <summary>
/// Compares two <see cref="SensorHandle"/> instances for inequality.
/// </summary>
/// <param name="left">The first SensorHandle.</param>
/// <param name="right">The second SensorHandle.</param>
/// <returns>Returns false if the two SensorHandles refer to the same sensor.</returns>
public static bool operator !=(SensorHandle left, SensorHandle right)
{
return !left.Equals(right);

/// Report a value-based data for this annotation.
/// </summary>
/// <param name="values">The annotation data.</param>
/// <typeparam name="T">The type of the data.</typeparam>
/// <exception cref="ArgumentNullException">Thrown if values is null</exception>
public void ReportValues<T>(T[] values)
{

/// <returns>A handle to an AsyncMetric, which can be used to report values for this metric in future frames.</returns>
public AsyncMetric ReportMetricAsync(MetricDefinition metricDefinition) => SimulationManager.SimulationState.CreateAsyncMetric(metricDefinition, SensorHandle, this);
/// <inheritdoc/>
/// <inheritdoc/>
/// <inheritdoc/>
public override int GetHashCode()
{
return Id.GetHashCode();

this.Description = description;
}
/// <inheritdoc/>
/// <inheritdoc/>
/// <inheritdoc/>
/// <summary>
/// Compares two <see cref="EgoHandle"/> instances for equality.
/// </summary>
/// <param name="left">The first EgoHandle.</param>
/// <param name="right">The second EgoHandle.</param>
/// <returns>Returns true if the two EgoHandles refer to the same ego.</returns>
/// <summary>
/// Compares two <see cref="EgoHandle"/> instances for inequality.
/// </summary>
/// <param name="left">The first EgoHandle.</param>
/// <param name="right">The second EgoHandle.</param>
/// <returns>Returns true if the two EgoHandles refer to the same ego.</returns>
public static bool operator !=(EgoHandle left, EgoHandle right)
{
return !left.Equals(right);

/// <summary>
/// Create a new SensorSpatialData with the given values.
/// </summary>
/// <param name="egoPose">The pose of the ego.</param>
/// <param name="sensorPose">The pose of the sensor relative to the ego.</param>
/// <param name="egoVelocity">The velocity of the ego.</param>
/// <param name="egoAcceleration">The acceleration of the ego.</param>
public SensorSpatialData(Pose egoPose, Pose sensorPose, Vector3? egoVelocity, Vector3? egoAcceleration)
{
EgoPose = egoPose;

/// </summary>
/// <param name="ego">The ego GameObject.</param>
/// <param name="sensor">The sensor GameObject.</param>
/// <returns></returns>
/// <returns>Returns a SensorSpatialData filled out with EgoPose and SensorPose based on the given objects.</returns>
public static SensorSpatialData FromGameObjects(GameObject ego, GameObject sensor)
{
ego = ego == null ? sensor : ego;

5
com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs


using UnityEngine.TestTools;
#if HDRP_PRESENT
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering.HighDefinition;
#endif

var InstanceSegmentationPass = new InstanceSegmentationPass()
{
targetCamera = camera,
targetTexture = rt,
idStart = 1,
idStep = 1
targetTexture = rt
};
InstanceSegmentationPass.name = nameof(InstanceSegmentationPass);
InstanceSegmentationPass.EnsureInit();

13
com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs


using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Experimental.Rendering;
#endif
using UnityEngine.Perception.Sensors;
using UnityEngine.TestTools;
using Object = UnityEngine.Object;

customPassVolume.isGlobal = true;
var rt = new RenderTexture(128, 128, 1, GraphicsFormat.R8G8B8A8_UNorm);
rt.Create();
var InstanceSegmentationPass = new InstanceSegmentationPass();
InstanceSegmentationPass.targetCamera = camera;
InstanceSegmentationPass.targetTexture = rt;
customPassVolume.customPasses.Add(InstanceSegmentationPass);
InstanceSegmentationPass.name = nameof(InstanceSegmentationPass);
InstanceSegmentationPass.EnsureInit();
var instanceSegmentationPass = new InstanceSegmentationPass();
instanceSegmentationPass.targetCamera = camera;
instanceSegmentationPass.targetTexture = rt;
customPassVolume.customPasses.Add(instanceSegmentationPass);
instanceSegmentationPass.name = nameof(instanceSegmentationPass);
instanceSegmentationPass.EnsureInit();
var reader = cameraObject.AddComponent<ImageReaderBehaviour>();
reader.source = rt;

2
com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs


planeObject.transform.SetPositionAndRotation(new Vector3(0, 0, 10), Quaternion.Euler(90, 0, 0));
planeObject.transform.localScale = new Vector3(scale, -1, scale);
var labeling = planeObject.AddComponent<Labeling>();
labeling.classes.Add(label);
labeling.labels.Add(label);
return planeObject;
}
#if UNITY_EDITOR

正在加载...
取消
保存