Migrating to a newer version of perception
This commit is contained in:
Родитель
d6ddbf7fcf
Коммит
f641fea15a
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c049de042030bd7f7ef0ecd9b4d425397c7c0d646076ba773284dd16b377af45
|
||||
size 3380
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 55105c2d431c7164aa94083b57830489
|
||||
guid: d20af9ee69954464e8d7cc8643ff2135
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f1d8bce512404b5b9bcb8b70652a30accaf54349ad559692f532ed87010966f9
|
||||
size 4205
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5d4937a6364496402454f077bce9c6483cab84c4a710da9094fbc6b807f46441
|
||||
size 11287
|
||||
oid sha256:4bb16d8b0263adba7d68540f1bf551a33e5446355dd7e14487e92c1c340e7bd4
|
||||
size 11671
|
||||
|
|
|
@ -121,7 +121,7 @@ public class BackgroundGenerator : JobComponentSystem
|
|||
backgroundHueMaxOffset = init.AppParameters.BackgroundHueMaxOffset;
|
||||
initialized = true;
|
||||
|
||||
m_ScaleRangeMetric = SimulationManager.RegisterMetricDefinition("background scale range", "The range of scale factors used to place background objects each frame", k_BackgroundScaleMetricId);
|
||||
m_ScaleRangeMetric = DatasetCapture.RegisterMetricDefinition("background scale range", "The range of scale factors used to place background objects each frame", k_BackgroundScaleMetricId);
|
||||
}
|
||||
|
||||
protected override void OnCreate()
|
||||
|
@ -194,7 +194,7 @@ public class BackgroundGenerator : JobComponentSystem
|
|||
var placementOrigin = new Vector3(placementRegion.x, placementRegion.y,
|
||||
k_PlacementDistance + cameraTf.position.z);
|
||||
|
||||
SimulationManager.ReportMetric(m_ScaleRangeMetric, $@"[ {{ ""scaleMin"": {scaleMin}, ""scaleMax"": {scaleMax} }}]");
|
||||
DatasetCapture.ReportMetric(m_ScaleRangeMetric, $@"[ {{ ""scaleMin"": {scaleMin}, ""scaleMax"": {scaleMax} }}]");
|
||||
|
||||
var meshesToDraw = new NativeArray<MeshDrawInfo>(numCellsHorizontal * numCellsVertical * numFillPasses, Allocator.TempJob);
|
||||
using (s_PlaceBackgroundObjects.Auto())
|
||||
|
|
|
@ -64,7 +64,7 @@ unsafe public class ForegroundObjectPlacer : JobComponentSystem
|
|||
m_ResourceDirectoriesQuery = EntityManager.CreateEntityQuery(typeof(ResourceDirectories));
|
||||
|
||||
m_CurriculumQuery = EntityManager.CreateEntityQuery(typeof(CurriculumState));
|
||||
m_ForegroundPlacementInfoDefinition = SimulationManager.RegisterMetricDefinition("foreground placement info", description: "Info about each object placed in the foreground layer. Currently only includes label and orientation.",id: new Guid(k_ForegroundPlacementInfoMetricGuid));
|
||||
m_ForegroundPlacementInfoDefinition = DatasetCapture.RegisterMetricDefinition("foreground placement info", description: "Info about each object placed in the foreground layer. Currently only includes label and orientation.",id: new Guid(k_ForegroundPlacementInfoMetricGuid));
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
public void LoadAndStartRenderDocCapture(out UnityEditor.EditorWindow gameView)
|
||||
|
@ -138,7 +138,7 @@ unsafe public class ForegroundObjectPlacer : JobComponentSystem
|
|||
using (s_PlaceObjects.Auto())
|
||||
placedObjectBoundingBoxes = PlaceObjects(camera, statics, occludingObjectBounds, ref curriculumState);
|
||||
|
||||
ReportObjectStats(placedObjectBoundingBoxes, m_CameraContainer);
|
||||
ReportObjectStats(statics, placedObjectBoundingBoxes, m_CameraContainer);
|
||||
|
||||
using (s_PlaceOccludingObjects.Auto())
|
||||
{
|
||||
|
@ -152,16 +152,15 @@ unsafe public class ForegroundObjectPlacer : JobComponentSystem
|
|||
return inputDeps;
|
||||
}
|
||||
|
||||
void ReportObjectStats(NativeList<PlacedObject> placedObjectBoundingBoxes, GameObject cameraObject)
|
||||
void ReportObjectStats(PlacementStatics placementStatics, NativeList<PlacedObject> placedObjectBoundingBoxes, GameObject cameraObject)
|
||||
{
|
||||
var perceptionCamera = cameraObject.GetComponent<PerceptionCamera>();
|
||||
var objectStates = new JArray();
|
||||
for (int i = 0; i < placedObjectBoundingBoxes.Length; i++)
|
||||
{
|
||||
var placedObject = placedObjectBoundingBoxes[i];
|
||||
var labeling = m_ParentForeground.transform.GetChild(placedObject.PrefabIndex).gameObject.GetComponent<Labeling>();
|
||||
int labelId;
|
||||
if (perceptionCamera.LabelingConfiguration.TryGetMatchingConfigurationEntry(labeling, out LabelEntry labelEntry))
|
||||
if (placementStatics.IdLabelConfig.TryGetMatchingConfigurationEntry(labeling, out IdLabelEntry labelEntry))
|
||||
labelId = labelEntry.id;
|
||||
else
|
||||
labelId = -1;
|
||||
|
@ -172,7 +171,7 @@ unsafe public class ForegroundObjectPlacer : JobComponentSystem
|
|||
jObject["rotation"] = new JRaw($"[{rotationEulerAngles.x}, {rotationEulerAngles.y}, {rotationEulerAngles.z}]");
|
||||
objectStates.Add(jObject);
|
||||
}
|
||||
SimulationManager.ReportMetric(m_ForegroundPlacementInfoDefinition, objectStates.ToString(Formatting.Indented));
|
||||
DatasetCapture.ReportMetric(m_ForegroundPlacementInfoDefinition, objectStates.ToString(Formatting.Indented));
|
||||
}
|
||||
|
||||
struct PlacedObject : IEquatable<PlacedObject>
|
||||
|
|
|
@ -26,7 +26,7 @@ public class LightingRandomizerSystem : JobComponentSystem
|
|||
if (light == null)
|
||||
return;
|
||||
|
||||
m_LightingInfoDefinition = SimulationManager.RegisterMetricDefinition("lighting info", "Per-frame light color and orientation", id: k_LightingInfoGuid);
|
||||
m_LightingInfoDefinition = DatasetCapture.RegisterMetricDefinition("lighting info", "Per-frame light color and orientation", id: k_LightingInfoGuid);
|
||||
m_Light = light.GetComponent<Light>();
|
||||
// To simulate phong shading we turn off shadows
|
||||
m_Light.shadows = LightShadows.None;
|
||||
|
@ -73,7 +73,7 @@ public class LightingRandomizerSystem : JobComponentSystem
|
|||
0f
|
||||
);
|
||||
|
||||
SimulationManager.ReportMetric(m_LightingInfoDefinition, new[]
|
||||
DatasetCapture.ReportMetric(m_LightingInfoDefinition, new[]
|
||||
{
|
||||
new LightInfo()
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ using Unity.Entities;
|
|||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.Perception.GroundTruth;
|
||||
using Random = Unity.Mathematics.Random;
|
||||
|
||||
public struct CurriculumState : IComponentData
|
||||
|
@ -29,8 +30,9 @@ public class PlacementStatics : Component
|
|||
public readonly NativeArray<Quaternion> InPlaneRotations;
|
||||
public readonly NativeArray<Quaternion> OutOfPlaneRotations;
|
||||
public readonly NativeArray<float> ScaleFactors;
|
||||
public readonly IdLabelConfig IdLabelConfig;
|
||||
|
||||
public PlacementStatics(int maxFrames, int maxForegroundObjectsPerFrame, float scalingMin, float scalingSize, float occludingHueMaxOffset, float backgroundObjectInForegroundChance, GameObject[] foreground, GameObject[] backgroundPrefabs, Texture2D[] backgroundImages, NativeArray<Quaternion> inPlaneRot, NativeArray<Quaternion> outPlaneRot, NativeArray<float> scaleFactors)
|
||||
public PlacementStatics(int maxFrames, int maxForegroundObjectsPerFrame, float scalingMin, float scalingSize, float occludingHueMaxOffset, float backgroundObjectInForegroundChance, GameObject[] foreground, GameObject[] backgroundPrefabs, Texture2D[] backgroundImages, NativeArray<Quaternion> inPlaneRot, NativeArray<Quaternion> outPlaneRot, NativeArray<float> scaleFactors, IdLabelConfig idLabelConfig)
|
||||
{
|
||||
MaxFrames = maxFrames;
|
||||
ForegroundPrefabs = foreground;
|
||||
|
@ -38,6 +40,7 @@ public class PlacementStatics : Component
|
|||
InPlaneRotations = inPlaneRot;
|
||||
OutOfPlaneRotations = outPlaneRot;
|
||||
ScaleFactors = scaleFactors;
|
||||
IdLabelConfig = idLabelConfig;
|
||||
ScalingMin = scalingMin;
|
||||
ScalingSize = scalingSize;
|
||||
OccludingHueMaxOffset = occludingHueMaxOffset;
|
||||
|
|
|
@ -39,6 +39,7 @@ public class ProjectInitialization : MonoBehaviour
|
|||
public AppParams AppParameters = AppParamDefaults;
|
||||
public bool EnableProfileLog;
|
||||
public PerceptionCamera PerceptionCamera;
|
||||
public IdLabelConfig idLabelconfig;
|
||||
Entity m_ResourceDirectoriesEntity;
|
||||
Entity m_CurriculumStateEntity;
|
||||
string m_ProfileLogPath;
|
||||
|
@ -92,10 +93,11 @@ public class ProjectInitialization : MonoBehaviour
|
|||
backgroundImages,
|
||||
ObjectPlacementUtilities.GenerateInPlaneRotationCurriculum(Allocator.Persistent),
|
||||
ObjectPlacementUtilities.GenerateOutOfPlaneRotationCurriculum(Allocator.Persistent),
|
||||
new NativeArray<float>(AppParameters.ScaleFactors, Allocator.Persistent));
|
||||
var appParamsMetricDefinition = SimulationManager.RegisterMetricDefinition(
|
||||
new NativeArray<float>(AppParameters.ScaleFactors, Allocator.Persistent),
|
||||
idLabelconfig);
|
||||
var appParamsMetricDefinition = DatasetCapture.RegisterMetricDefinition(
|
||||
"app-params", description:"The values from the app-params used in the simulation. Only triggered once per simulation.", id: k_AppParamsMetricGuid);
|
||||
SimulationManager.ReportMetric(appParamsMetricDefinition, new[] {AppParameters});
|
||||
DatasetCapture.ReportMetric(appParamsMetricDefinition, new[] {AppParameters});
|
||||
m_CurriculumStateEntity = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity();
|
||||
World.DefaultGameObjectInjectionWorld.EntityManager.AddComponentData(
|
||||
m_CurriculumStateEntity, new CurriculumState());
|
||||
|
@ -151,13 +153,17 @@ public class ProjectInitialization : MonoBehaviour
|
|||
|
||||
void ValidateForegroundLabeling(GameObject[] foregroundObjects, PerceptionCamera perceptionCamera)
|
||||
{
|
||||
if (perceptionCamera.LabelingConfiguration == null)
|
||||
|
||||
var boundingBox2DLabeler = (BoundingBox2DLabeler)perceptionCamera.labelers.First(l => l is BoundingBox2DLabeler);
|
||||
if (boundingBox2DLabeler == null)
|
||||
return;
|
||||
var labelConfig = boundingBox2DLabeler.idLabelConfig;
|
||||
if (labelConfig == null)
|
||||
{
|
||||
Debug.LogError("PerceptionCamera does not have a labeling configuration. This will likely cause the program to fail.");
|
||||
return;
|
||||
}
|
||||
|
||||
var labelingConfiguration = perceptionCamera.LabelingConfiguration;
|
||||
var regex = new Regex(".*_[0-9][0-9]");
|
||||
var foregroundNames = foregroundObjects.Select(f =>
|
||||
{
|
||||
|
@ -166,8 +172,8 @@ public class ProjectInitialization : MonoBehaviour
|
|||
foregroundName = foregroundName.Substring(0, foregroundName.Length - 3);
|
||||
return foregroundName;
|
||||
}).ToList();
|
||||
var foregroundObjectsMissingFromConfig = foregroundNames.Where(f => labelingConfiguration.LabelEntries.All(l => l.label != f)).ToList();
|
||||
var configurationsMissingModel = labelingConfiguration.LabelEntries.Skip(1).Select(l => l.label).Where(l => !foregroundNames.Any(f => f == l)).ToList();
|
||||
var foregroundObjectsMissingFromConfig = foregroundNames.Where(f => labelConfig.labelEntries.All(l => l.label != f)).ToList();
|
||||
var configurationsMissingModel = labelConfig.labelEntries.Skip(1).Select(l => l.label).Where(l => !foregroundNames.Any(f => f == l)).ToList();
|
||||
|
||||
if (foregroundObjectsMissingFromConfig.Count > 0)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ public class RandomizedPostProcessingFeature : ScriptableRendererFeature
|
|||
m_RenderPass = new RandomizedPostProcessingPass();
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
m_PostProcessValuesMetric = SimulationManager.RegisterMetricDefinition(
|
||||
m_PostProcessValuesMetric = DatasetCapture.RegisterMetricDefinition(
|
||||
"random post processing",
|
||||
description: "Some post-processing parameters are randomized each frame. These are the per-frame values used.",
|
||||
id: k_PostProcessValuesMetricId);
|
||||
|
@ -122,7 +122,7 @@ public class RandomizedPostProcessingFeature : ScriptableRendererFeature
|
|||
blur_std_dev_uv = stdDev,
|
||||
noise_strength = noiseStrength
|
||||
};
|
||||
SimulationManager.ReportMetric(m_PostProcessValuesMetric, new[] { metric });
|
||||
DatasetCapture.ReportMetric(m_PostProcessValuesMetric, new[] { metric });
|
||||
}
|
||||
|
||||
m_RenderPass.Update(m_BlurMaterial, m_NoiseMaterial, RenderEvent,
|
||||
|
|
Загрузка…
Ссылка в новой задаче