GitHub
5 年前
当前提交
0ffef165
共有 21 个文件被更改,包括 305 次插入 和 69 次删除
-
8TestProjects/PerceptionHDRP/Packages/manifest.json
-
5TestProjects/PerceptionHDRP/ProjectSettings/HDRPProjectSettings.asset
-
4TestProjects/PerceptionHDRP/ProjectSettings/ProjectVersion.txt
-
8TestProjects/PerceptionHDRP/ProjectSettings/VFXManager.asset
-
6com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
-
14com.unity.perception/Tests/Editor/Unity.Perception.Editor.Tests.asmdef
-
36com.unity.perception/Tests/Runtime/GroundTruthTests/BoundingBox2DTests.cs
-
6com.unity.perception/Tests/Runtime/GroundTruthTests/Main Camera.prefab
-
4com.unity.perception/Tests/Runtime/GroundTruthTests/ObjectCountTests.cs
-
12com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManagerTests.cs
-
6com.unity.perception/Tests/Runtime/GroundTruthTests/SimulationManager_SensorSchedulingTests.cs
-
2com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs
-
77com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs
-
3com.unity.perception/Tests/Editor/PerceptionCameraEditorTests.cs.meta
-
37com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs
-
112com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs
-
3com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs.meta
-
31com.unity.perception/Tests/Runtime/GroundTruthTests/PassTestBase.cs
-
0/com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs.meta
-
0/com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs
-
0/com.unity.perception/Tests/Runtime/GroundTruthTests/GroundTruthTestBase.cs.meta
|
|||
m_EditorVersion: 2019.3.6f1 |
|||
m_EditorVersionWithRevision: 2019.3.6f1 (5c3fb0a11183) |
|||
m_EditorVersion: 2019.3.9f1 |
|||
m_EditorVersionWithRevision: 2019.3.9f1 (e6e740a1c473) |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using NUnit.Framework; |
|||
using Unity.Collections; |
|||
using UnityEditor; |
|||
using UnityEditor.SceneManagement; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception; |
|||
using UnityEngine.Perception.Sensors; |
|||
using UnityEngine.TestTools; |
|||
|
|||
namespace EditorTests |
|||
{ |
|||
[TestFixture] |
|||
public class PerceptionCameraEditorTests |
|||
{ |
|||
[UnityTest] |
|||
public IEnumerator EditorPause_DoesNotLogErrors() |
|||
{ |
|||
int sceneCount = EditorSceneManager.sceneCount; |
|||
for (int i = sceneCount - 1; i >= 0; i--) |
|||
{ |
|||
EditorSceneManager.CloseScene(EditorSceneManager.GetSceneAt(i), true); |
|||
} |
|||
|
|||
EditorSceneManager.NewScene(NewSceneSetup.EmptyScene); |
|||
SetupCamera(ScriptableObject.CreateInstance<LabelingConfiguration>()); |
|||
yield return new EnterPlayMode(); |
|||
var expectedFirstFrame = Time.frameCount; |
|||
yield return null; |
|||
EditorApplication.isPaused = true; |
|||
//Wait a few editor frames to ensure the issue has a chance to trigger.
|
|||
yield return null; |
|||
yield return null; |
|||
yield return null; |
|||
yield return null; |
|||
EditorApplication.isPaused = false; |
|||
var expectedLastFrame = Time.frameCount; |
|||
yield return null; |
|||
|
|||
SimulationManager.ResetSimulation(); |
|||
|
|||
var capturesPath = Path.Combine(SimulationManager.OutputDirectory, "captures_000.json"); |
|||
var capturesJson = File.ReadAllText(capturesPath); |
|||
for (int iFrameCount = expectedFirstFrame; iFrameCount <= expectedLastFrame; iFrameCount++) |
|||
{ |
|||
var imagePath = Path.Combine(PerceptionCamera.RgbDirectory, $"rgb_{iFrameCount}").Replace(@"\", @"\\"); |
|||
StringAssert.Contains(imagePath, capturesJson); |
|||
} |
|||
|
|||
yield return new ExitPlayMode(); |
|||
} |
|||
|
|||
static GameObject SetupCamera(LabelingConfiguration labelingConfiguration) |
|||
{ |
|||
var cameraObject = new GameObject(); |
|||
cameraObject.SetActive(false); |
|||
var camera = cameraObject.AddComponent<Camera>(); |
|||
camera.orthographic = true; |
|||
camera.orthographicSize = 1; |
|||
#if HDRP_PRESENT
|
|||
cameraObject.AddComponent<UnityEngine.Rendering.HighDefinition.HDAdditionalCameraData>(); |
|||
#endif
|
|||
|
|||
var perceptionCamera = cameraObject.AddComponent<PerceptionCamera>(); |
|||
perceptionCamera.LabelingConfiguration = labelingConfiguration; |
|||
perceptionCamera.captureRgbImages = true; |
|||
perceptionCamera.produceBoundingBoxAnnotations = true; |
|||
perceptionCamera.produceObjectCountAnnotations = true; |
|||
|
|||
cameraObject.SetActive(true); |
|||
return cameraObject; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6efa744f46fc41e8aa4296d99f4c66c9 |
|||
timeCreated: 1587395248 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using NUnit.Framework; |
|||
using Unity.Simulation; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace GroundTruthTests |
|||
{ |
|||
public class GroundTruthTestBase |
|||
{ |
|||
List<GameObject> objectsToDestroy = new List<GameObject>(); |
|||
[TearDown] |
|||
public void TearDown() |
|||
{ |
|||
foreach (var o in objectsToDestroy) |
|||
Object.DestroyImmediate(o); |
|||
|
|||
objectsToDestroy.Clear(); |
|||
|
|||
SimulationManager.ResetSimulation(); |
|||
Time.timeScale = 1; |
|||
if (Directory.Exists(SimulationManager.OutputDirectory)) |
|||
Directory.Delete(SimulationManager.OutputDirectory, true); |
|||
} |
|||
|
|||
public void AddTestObjectForCleanup(GameObject @object) => objectsToDestroy.Add(@object); |
|||
|
|||
public void DestroyTestObject(GameObject @object) |
|||
{ |
|||
Object.DestroyImmediate(@object); |
|||
objectsToDestroy.Remove(@object); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using NUnit.Framework; |
|||
using Unity.Collections; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception; |
|||
using UnityEngine.Perception.Sensors; |
|||
using UnityEngine.TestTools; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace GroundTruthTests |
|||
{ |
|||
#if HDRP_PRESENT
|
|||
[Ignore("Ignoring in HDRP because of a rendering issue in the first frame. See issue AISV-455.")] |
|||
#endif
|
|||
public class PerceptionCameraIntegrationTests : GroundTruthTestBase |
|||
{ |
|||
[UnityTest] |
|||
[UnityPlatform(RuntimePlatform.LinuxPlayer, RuntimePlatform.WindowsPlayer)] |
|||
public IEnumerator EnableBoundingBoxes_GeneratesCorrectDataset() |
|||
{ |
|||
//set resolution to ensure we don't have rounding in rendering leading to bounding boxes to change height/width
|
|||
Screen.SetResolution(400, 400, false); |
|||
//give the screen a chance to resize
|
|||
yield return null; |
|||
|
|||
var jsonExpected = $@" {{
|
|||
""label_id"": 0, |
|||
""label_name"": ""label"", |
|||
""instance_id"": 1, |
|||
""x"": 0.0, |
|||
""y"": {Screen.height / 4:F1}, |
|||
""width"": {Screen.width:F1}, |
|||
""height"": {Screen.height / 2:F1} |
|||
}}";
|
|||
var labelingConfiguration = CreateLabelingConfiguration(); |
|||
var camera = SetupCamera(labelingConfiguration, pc => |
|||
{ |
|||
pc.produceBoundingBoxAnnotations = true; |
|||
}); |
|||
|
|||
var plane = TestHelper.CreateLabeledPlane(); |
|||
AddTestObjectForCleanup(plane); |
|||
//a plane is 10x10 by default, so scale it down to be 10x1 to cover the center half of the image
|
|||
plane.transform.localScale = new Vector3(10f, -1f, .1f); |
|||
yield return null; |
|||
SimulationManager.ResetSimulation(); |
|||
|
|||
var capturesPath = Path.Combine(SimulationManager.OutputDirectory, "captures_000.json"); |
|||
var capturesJson = File.ReadAllText(capturesPath); |
|||
StringAssert.Contains(jsonExpected, capturesJson); |
|||
} |
|||
|
|||
[UnityTest] |
|||
public IEnumerator EnableSemanticSegmentation_GeneratesCorrectDataset() |
|||
{ |
|||
var labelingConfiguration = CreateLabelingConfiguration(); |
|||
SetupCamera(labelingConfiguration, pc => pc.produceSegmentationImages = true); |
|||
|
|||
string expectedImageFilename = $"segmentation_{Time.frameCount}.png"; |
|||
|
|||
this.AddTestObjectForCleanup(TestHelper.CreateLabeledPlane()); |
|||
yield return null; |
|||
SimulationManager.ResetSimulation(); |
|||
|
|||
var capturesPath = Path.Combine(SimulationManager.OutputDirectory, "captures_000.json"); |
|||
var capturesJson = File.ReadAllText(capturesPath); |
|||
var imagePath = Path.Combine("SemanticSegmentation", expectedImageFilename).Replace(@"\", @"\\"); |
|||
StringAssert.Contains(imagePath, capturesJson); |
|||
} |
|||
|
|||
static LabelingConfiguration CreateLabelingConfiguration() |
|||
{ |
|||
var label = "label"; |
|||
var labelingConfiguration = ScriptableObject.CreateInstance<LabelingConfiguration>(); |
|||
|
|||
labelingConfiguration.LabelingConfigurations = new List<LabelingConfigurationEntry> |
|||
{ |
|||
new LabelingConfigurationEntry |
|||
{ |
|||
label = label, |
|||
value = 500 |
|||
} |
|||
}; |
|||
return labelingConfiguration; |
|||
} |
|||
|
|||
GameObject SetupCamera(LabelingConfiguration labelingConfiguration, Action<PerceptionCamera> initPerceptionCamera) |
|||
{ |
|||
var cameraObject = new GameObject(); |
|||
cameraObject.SetActive(false); |
|||
var camera = cameraObject.AddComponent<Camera>(); |
|||
camera.orthographic = true; |
|||
camera.orthographicSize = 1; |
|||
|
|||
var perceptionCamera = cameraObject.AddComponent<PerceptionCamera>(); |
|||
perceptionCamera.produceSegmentationImages = false; |
|||
perceptionCamera.produceVisiblePixelsMetric = false; |
|||
perceptionCamera.produceBoundingBoxAnnotations = false; |
|||
perceptionCamera.produceObjectCountAnnotations = false; |
|||
perceptionCamera.captureRgbImages = false; |
|||
perceptionCamera.LabelingConfiguration = labelingConfiguration; |
|||
initPerceptionCamera(perceptionCamera); |
|||
|
|||
cameraObject.SetActive(true); |
|||
AddTestObjectForCleanup(cameraObject); |
|||
return cameraObject; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f83408fe81fd4168a740139c98a38cfe |
|||
timeCreated: 1586791038 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace GroundTruthTests |
|||
{ |
|||
public class PassTestBase |
|||
{ |
|||
List<GameObject> objectsToDestroy = new List<GameObject>(); |
|||
[TearDown] |
|||
public void TearDown() |
|||
{ |
|||
foreach (var o in objectsToDestroy) |
|||
Object.DestroyImmediate(o); |
|||
|
|||
objectsToDestroy.Clear(); |
|||
SimulationManager.ResetSimulation(); |
|||
} |
|||
|
|||
public void AddTestObjectForCleanup(GameObject @object) => objectsToDestroy.Add(@object); |
|||
|
|||
public void DestroyTestObject(GameObject @object) |
|||
{ |
|||
Object.DestroyImmediate(@object); |
|||
objectsToDestroy.Remove(@object); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue