浏览代码

Adding multi-camera segmentation tests

/multipleCameras
Jon Hogins 4 年前
当前提交
411de00e
共有 1 个文件被更改,包括 42 次插入0 次删除
  1. 42
      com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs

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


}
[UnityTest]
public IEnumerator SegmentationPass_WithMultipleCameras_ProducesCorrectValues([Values(SegmentationKind.Instance, SegmentationKind.Semantic)] SegmentationKind segmentationKind)
{
int timesSegmentationImageReceivedCam1 = 0;
int timesSegmentationImageReceivedCam2 = 0;
object expectedPixelValue = segmentationKind == SegmentationKind.Instance ? (object) new Color32(255, 0, 0, 255) : k_SemanticPixelValue;
void OnSegmentationImageReceivedCam1(NativeArray<Color32> data)
{
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, data.Length), data);
timesSegmentationImageReceivedCam1++;
}
void OnSegmentationImageReceivedCam2(NativeArray<Color32> data)
{
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, data.Length), data);
timesSegmentationImageReceivedCam2++;
}
GameObject cameraObject1 = null;
GameObject cameraObject2 = null;
switch (segmentationKind)
{
case SegmentationKind.Instance:
cameraObject1 = SetupCameraSemanticSegmentation(a => OnSegmentationImageReceivedCam1(a.data), false);
cameraObject2 = SetupCameraSemanticSegmentation(a => OnSegmentationImageReceivedCam2(a.data), false);
break;
case SegmentationKind.Semantic:
cameraObject1 = SetupCameraInstanceSegmentation((size, data, renderTexture) => OnSegmentationImageReceivedCam1(data));
cameraObject2 = SetupCameraInstanceSegmentation((size, data, renderTexture) => OnSegmentationImageReceivedCam2(data));
break;
}
var plane = TestHelper.CreateLabeledPlane();
AddTestObjectForCleanup(plane);
yield return null;
//destroy the object to force all pending segmented image readbacks to finish and events to be fired.
DestroyTestObject(cameraObject1);
DestroyTestObject(cameraObject2);
Assert.AreEqual(1, timesSegmentationImageReceivedCam1);
Assert.AreEqual(1, timesSegmentationImageReceivedCam2);
}
[UnityTest]
public IEnumerator SegmentationPassProducesCorrectValuesEachFrame(
[Values(SegmentationKind.Instance, SegmentationKind.Semantic)] SegmentationKind segmentationKind)
{

正在加载...
取消
保存