浏览代码

Graceful-ish handling of more than 1 perception camera for visualization

/aisv647_visualizations
Steven Borkman 4 年前
当前提交
8716f467
共有 6 个文件被更改,包括 32 次插入54 次删除
  1. 46
      TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
  2. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs
  3. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs
  4. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs
  5. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
  6. 32
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs

46
TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity


m_Name:
m_EditorClassIdentifier:
cam: {fileID: 963194229}
renderTexture: {fileID: 0}
secondCamera: {fileID: 0}
--- !u!1 &1640252278
GameObject:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
--- !u!1 &1784690340
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1784690342}
- component: {fileID: 1784690341}
m_Layer: 0
m_Name: VisualizationManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1784690341
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1784690340}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 53f4c974fdf704444959724a41de0cfe, type: 3}
m_Name:
m_EditorClassIdentifier:
cam: {fileID: 963194229}
--- !u!4 &1784690342
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1784690340}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1862.3339, y: 948.3081, z: 49.613728}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

2
com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs


if (!CaptureOptions.useAsyncReadbackIfSupported && frameCount != Time.frameCount)
Debug.LogWarning("Not on current frame: " + frameCount + "(" + Time.frameCount + ")");
if (visualizationEnabled)
if (perceptionCamera.visualizationEnabled && visualizationEnabled)
{
Visualize();
}

2
com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs


count = counts[i]
};
if (visualizationEnabled)
if (visualizationEnabled && perceptionCamera.visualizationEnabled)
{
if (entryToLabelMap == null) entryToLabelMap = new Dictionary<string, string>();

2
com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs


visible_pixels = objectInfo.pixelCount
};
if (visualizationEnabled)
if (visualizationEnabled && perceptionCamera.visualizationEnabled)
{
if (entryToLabelMap == null) entryToLabelMap = new Dictionary<string, string>();

2
com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs


var asyncRequest = Manager.Instance.CreateRequest<AsyncRequest<AsyncSemanticSegmentationWrite>>();
if (visualizationEnabled)
if (visualizationEnabled && perceptionCamera.visualizationEnabled)
VisualizeSegmentationTexture(data, targetTexture);
imageReadback?.Invoke(new ImageReadbackEventArgs

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


using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

bool m_GroundTruthRendererFeatureRun;
private static Camera visualizationCamera;
/// <summary>
/// Should the labeling visualization routines run for this camera. This will only
/// be set to false if there is more than one camera in the scene, and this is
/// not considered the active camera.
/// </summary>
bool m_VisualizationEnabled = true;
public bool visualizationEnabled
{
get
{
return m_VisualizationEnabled;
}
}
/// <summary>
/// The <see cref="SensorHandle"/> associated with this camera. Use this to report additional annotations and metrics at runtime.

void Start()
{
SetupVisualizationCamera();
var cam = GetComponent<Camera>();
cam.enabled = false;
SetupVisualizationCamera(cam);
void SetupVisualizationCamera()
bool SetupVisualizationCamera(Camera cam)
{
var cam = GetComponent<Camera>();
cam.enabled = false;
m_VisualizationEnabled = false;
return false;
}
// set up to render to a render texture instead of the screen
var visualizationRenderTexture = new RenderTexture(new RenderTextureDescriptor(cam.pixelWidth, cam.pixelHeight, UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_UNorm, 8));

rect.pivot = new Vector2(0.5f, 0.5f);
rect.offsetMax = Vector2.zero;
rect.offsetMin = Vector2.zero;
return true;
}
void CheckForRendererFeature(ScriptableRenderContext context, Camera camera)

正在加载...
取消
保存