浏览代码

addressed PR feedback

/main
sleal-unity 4 年前
当前提交
55c63ba0
共有 3 个文件被更改,包括 13 次插入14 次删除
  1. 2
      com.unity.perception/CHANGELOG.md
  2. 13
      com.unity.perception/Runtime/GroundTruth/Labeling/LabelManager.cs
  3. 12
      com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs

2
com.unity.perception/CHANGELOG.md


The PerceptionScenario abstract class has been added to abstract perception data capture specific functionality from the vanilla scenario lifecycle.
The newly added LabelManager class now enables custom Labelers to access the list of registered Labeling Components present in the scene
### Changed
Renamed all appearances of the term `KeyPoint` within types and names to `Keypoint`.

13
com.unity.perception/Runtime/GroundTruth/Labeling/LabelManager.cs


/// <summary>
/// Manages the registration of <see cref="Labeling"/> components
/// </summary>
[DefaultExecutionOrder(1)]
public class LabelManager
{
/// <summary>

const uint k_StartingIndex = 1;
uint m_CurrentObjectIndex = k_StartingIndex;
uint m_NextObjectIndex = k_StartingIndex;
List<IGroundTruthGenerator> m_ActiveGenerators = new List<IGroundTruthGenerator>();
LinkedHashSet<Labeling> m_LabelsPendingRegistration = new LinkedHashSet<Labeling>();
LinkedHashSet<Labeling> m_RegisteredLabels = new LinkedHashSet<Labeling>();

public void RegisterPendingLabels()
{
if (m_RegisteredLabels.Count == 0)
m_CurrentObjectIndex = k_StartingIndex;
m_NextObjectIndex = k_StartingIndex;
foreach (var unregisteredLabel in m_LabelsPendingRegistration)
{

var instanceId = m_CurrentObjectIndex++;
var instanceId = m_NextObjectIndex++;
RecursivelyInitializeGameObjects(
unregisteredLabel.gameObject,

/// Registers a labeling component
/// </summary>
/// <param name="labeledObject">the component to register</param>
public void Register(Labeling labeledObject)
internal void Register(Labeling labeledObject)
{
m_LabelsPendingRegistration.Add(labeledObject);
}

/// </summary>
/// <param name="labeledObject">the component to unregister</param>
public void Unregister(Labeling labeledObject)
internal void Unregister(Labeling labeledObject)
{
m_LabelsPendingRegistration.Remove(labeledObject);
m_RegisteredLabels.Remove(labeledObject);

/// list of labels changes or when renderers or materials change on objects in the hierarchy.
/// </summary>
/// <param name="labeledObject">the component to refresh</param>
public void RefreshLabeling(Labeling labeledObject)
internal void RefreshLabeling(Labeling labeledObject)
{
m_RegisteredLabels.Remove(labeledObject);
m_LabelsPendingRegistration.Add(labeledObject);

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


if (frameStart == null || frameStart > frameCount) return;
timesSegmentationImageReceived++;
for (var i = 0; i < data.Length; i++)
Assert.AreEqual(expectedPixelValue, data[i]);
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, data.Length), data.ToArray());
}
switch (segmentationKind)

void OnSegmentationImageReceived(NativeArray<Color32> data)
{
timesSegmentationImageReceived++;
for (var i = 0; i < data.Length; i++)
Assert.AreEqual(expectedPixelValue, data[i]);
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, data.Length), data.ToArray());
}
var cameraObject = SetupCameraSemanticSegmentation(a => OnSegmentationImageReceived(a.data), false);

void OnSegmentationImageReceived(NativeArray<Color32> data)
{
timesSegmentationImageReceived++;
for (var i = 0; i < data.Length; i++)
Assert.AreEqual(expectedPixelValue, data[i]);
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, data.Length), data.ToArray());
}
var cameraObject = SetupCameraSemanticSegmentation(a => OnSegmentationImageReceived(a.data), showVisualizations);

try
{
for (var i = 0; i < data.Length; i++)
Assert.AreEqual(expectedLabelAtFrame[frameCount], data[i]);
CollectionAssert.AreEqual(Enumerable.Repeat(expectedLabelAtFrame[frameCount], data.Length), data.ToArray());
}
// ReSharper disable once RedundantCatchClause

正在加载...
取消
保存