Steven Borkman
4 年前
当前提交
0645e2fb
共有 26 个文件被更改,包括 2174 次插入 和 509 次删除
-
9TestProjects/PerceptionURP/Assets/ExampleLabelingConfiguration.asset
-
2TestProjects/PerceptionURP/Assets/ExampleScripts/BoxToggleHandler.cs.meta
-
940TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
-
8TestProjects/PerceptionURP/Assets/Textures/outline_box.png
-
12TestProjects/PerceptionURP/Assets/Textures/outline_box.png.meta
-
182com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
-
3com.unity.perception/Runtime/GroundTruth/RenderTextureReader.cs
-
11TestProjects/PerceptionURP/Assets/Textures/Resources/OutlineMaterial.mat
-
26TestProjects/PerceptionURP/Assets/ExampleScripts/BoxToggleHandler.cs
-
27TestProjects/PerceptionURP/Assets/ExampleScripts/SegmentationToggleHandler.cs
-
11TestProjects/PerceptionURP/Assets/ExampleScripts/SegmentationToggleHandler.cs.meta
-
33TestProjects/PerceptionURP/Assets/ExampleScripts/TransparencySlider.cs
-
11TestProjects/PerceptionURP/Assets/ExampleScripts/TransparencySlider.cs.meta
-
8TestProjects/PerceptionURP/Assets/Fonts.meta
-
3TestProjects/PerceptionURP/Assets/Textures/sharp_done_white_18dp.png
-
104TestProjects/PerceptionURP/Assets/Textures/sharp_done_white_18dp.png.meta
-
1001TestProjects/PerceptionURP/Assets/Fonts/Inter-Light.otf
-
23TestProjects/PerceptionURP/Assets/Fonts/Inter-Light.otf.meta
-
107TestProjects/PerceptionURP/Assets/Textures/Resources/SegmentationMaterial.mat
-
8TestProjects/PerceptionURP/Assets/Textures/Resources/SegmentationMaterial.mat.meta
-
154TestProjects/PerceptionURP/Assets/ExampleScripts/BoundingBoxRenderer.cs
-
0/TestProjects/PerceptionURP/Assets/ExampleScripts/BoxToggleHandler.cs.meta
-
0/TestProjects/PerceptionURP/Assets/Textures/Resources/OutlineMaterial.mat
-
0/TestProjects/PerceptionURP/Assets/Textures/Resources/OutlineMaterial.mat.meta
940
TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
|
|||
public class BoxToggleHandler : MonoBehaviour |
|||
{ |
|||
public PerceptionCamera perceptionCamera; |
|||
|
|||
// Start is called before the first frame update
|
|||
void Start() |
|||
{ |
|||
|
|||
} |
|||
|
|||
// Update is called once per frame
|
|||
void Update() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public void OnToggle(bool enabled) |
|||
{ |
|||
perceptionCamera.SetBoundsVisualizationEnabled(enabled); |
|||
} |
|||
} |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
|
|||
public class SegmentationToggleHandler : MonoBehaviour |
|||
{ |
|||
public PerceptionCamera perceptionCamera; |
|||
|
|||
// Start is called before the first frame update
|
|||
void Start() |
|||
{ |
|||
// TODO set up the default toggle state based on
|
|||
// the perception cameras default values
|
|||
} |
|||
|
|||
// Update is called once per frame
|
|||
void Update() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public void OnToggled(bool enabled) |
|||
{ |
|||
perceptionCamera.SetEnableSegmentationVisualization(enabled); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c5d22ec68465e41e381d199c3d1b6f52 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.UI; |
|||
|
|||
public class TransparencySlider : MonoBehaviour |
|||
{ |
|||
public PerceptionCamera camera; |
|||
private Slider slider; |
|||
|
|||
private bool dontEcho = false; |
|||
|
|||
// Start is called before the first frame update
|
|||
void Start() |
|||
{ |
|||
slider = GetComponent<Slider>(); |
|||
dontEcho = true; |
|||
slider.value = camera.GetVisualizeSegmentationTextureTransparency(); |
|||
dontEcho = false; |
|||
} |
|||
|
|||
// Update is called once per frame
|
|||
void Update() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public void OnValueChanged(float updated) |
|||
{ |
|||
if (!dontEcho) camera.SetVisualizeSegmentationTextureTransparency(slider.value); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 18a20e306f5fe4bb4b0c0d913ded66da |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4875441768dda4ff1850815606f78cde |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2e218e2f433e54da9a576c807fbf99f9 |
|||
TextureImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 11 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 0 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
streamingMipmaps: 0 |
|||
streamingMipmapsPriority: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -100 |
|||
wrapU: 1 |
|||
wrapV: 1 |
|||
wrapW: -1 |
|||
nPOTScale: 0 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 1 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 1 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 8 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
applyGammaDecoding: 0 |
|||
platformSettings: |
|||
- serializedVersion: 3 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: Standalone |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: 5e97eb03825dee720800000000000000 |
|||
internalID: 0 |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
secondaryTextures: [] |
|||
spritePackingTag: |
|||
pSDRemoveMatte: 0 |
|||
pSDShowRemoveMatteOption: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
TestProjects/PerceptionURP/Assets/Fonts/Inter-Light.otf
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 807ae4a0302114abc9474a0222814b27 |
|||
TrueTypeFontImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 4 |
|||
fontSize: 16 |
|||
forceTextureCase: -2 |
|||
characterSpacing: 0 |
|||
characterPadding: 1 |
|||
includeFontData: 1 |
|||
fontName: Inter |
|||
fontNames: |
|||
- Inter |
|||
fallbackFontReferences: |
|||
- {fileID: 12800000, guid: cbeabcf7adb6f49e78f4d2bb72e7f376, type: 3} |
|||
customCharacters: |
|||
fontRenderingMode: 0 |
|||
ascentCalculationMode: 1 |
|||
useLegacyBoundsCalculation: 0 |
|||
shouldRoundAdvanceValue: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: SegmentationMaterial |
|||
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3} |
|||
m_ShaderKeywords: |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: 3050 |
|||
stringTagMap: |
|||
RenderType: Transparent |
|||
disabledShaderPasses: |
|||
- SHADOWCASTER |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _AlphaTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _BaseMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MaskTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _NormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _SpecGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _AlphaClip: 0 |
|||
- _Blend: 0 |
|||
- _BumpScale: 1 |
|||
- _Cull: 2 |
|||
- _Cutoff: 0.5 |
|||
- _DstBlend: 10 |
|||
- _EnableExternalAlpha: 0 |
|||
- _EnvironmentReflections: 1 |
|||
- _GlossMapScale: 0 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _QueueOffset: 0 |
|||
- _ReceiveShadows: 1 |
|||
- _SampleGI: 0 |
|||
- _Smoothness: 0.5 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 1 |
|||
- _SrcBlend: 5 |
|||
- _Surface: 1 |
|||
- _WorkflowMode: 1 |
|||
- _ZWrite: 0 |
|||
m_Colors: |
|||
- _BaseColor: {r: 1, g: 1, b: 1, a: 0.50980395} |
|||
- _Color: {r: 1, g: 1, b: 1, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|||
- _Flip: {r: 1, g: 1, b: 1, a: 1} |
|||
- _RendererColor: {r: 1, g: 1, b: 1, a: 1} |
|||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} |
|||
--- !u!114 &3089368426582508830 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 11 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
version: 1 |
|
|||
fileFormatVersion: 2 |
|||
guid: f562a5a621358402796352af288935cc |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using Unity.Collections; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.Rendering; |
|||
using Unity.Entities; |
|||
using Unity.Simulation; |
|||
|
|||
[RequireComponent(typeof(Camera))] |
|||
public class BoundingBoxRenderer : MonoBehaviour |
|||
{ |
|||
public GameObject light; |
|||
public GameObject target; |
|||
|
|||
private PerceptionCamera perception; |
|||
|
|||
private void Awake() |
|||
{ |
|||
perception = GetComponent<PerceptionCamera>(); |
|||
CaptureOptions.useAsyncReadbackIfSupported = false; |
|||
} |
|||
} |
|||
#if false
|
|||
private RenderTexture renderTexture = null; |
|||
private Texture2D cpuTexture = null; |
|||
|
|||
private AnnotationDefinition bbDef; |
|||
|
|||
private RenderedObjectInfoGenerator renderedObjectInfoGenerator; |
|||
|
|||
private RenderTextureReader<uint> segmentationReader; |
|||
|
|||
private void Awake() |
|||
{ |
|||
var cam = GetComponent<Camera>(); |
|||
var width = cam.pixelWidth; |
|||
var height = cam.pixelHeight; |
|||
|
|||
renderTexture = new RenderTexture(new RenderTextureDescriptor(width, height, GraphicsFormat.R8G8B8A8_UNorm, 8)); |
|||
renderTexture.name = "segmentation"; |
|||
|
|||
cpuTexture = new Texture2D(renderTexture.width, renderTexture.height, renderTexture.graphicsFormat, TextureCreationFlags.None); |
|||
|
|||
bbDef = SimulationManager.RegisterAnnotationDefinition( |
|||
"Target bounding box", |
|||
"The position of the target in the camera's local space", |
|||
id: Guid.Parse("C0B4A22C-0420-4D9F-BAFC-954B8F7B35A7")); |
|||
#if false
|
|||
renderedObjectInfoGenerator = new RenderedObjectInfoGenerator(labelingConfiguration); |
|||
World.DefaultGameObjectInjectionWorld.GetExistingSystem<GroundTruthLabelSetupSystem>().Activate(renderedObjectInfoGenerator); |
|||
|
|||
segmentationReader = new RenderTextureReader<uint>(segmentationTexture, cam, (frameCount, data, tex) => |
|||
{ |
|||
if (segmentationImageReceived != null) |
|||
segmentationImageReceived(frameCount, data); |
|||
|
|||
m_RenderedObjectInfoGenerator.Compute(data, tex.width, boundingBoxOrigin, out var renderedObjectInfos, out var classCounts, Allocator.Temp); |
|||
|
|||
using (s_RenderedObjectInfosCalculatedEvent.Auto()) |
|||
renderedObjectInfosCalculated?.Invoke(frameCount, renderedObjectInfos); |
|||
|
|||
if (produceObjectCountAnnotations) |
|||
OnObjectCountsReceived(classCounts, LabelingConfiguration.LabelEntries, frameCount); |
|||
|
|||
if (produceBoundingBoxAnnotations) |
|||
ProduceBoundingBoxesAnnotation(renderedObjectInfos, LabelingConfiguration.LabelEntries, frameCount); |
|||
|
|||
if (produceRenderedObjectInfoMetric) |
|||
ProduceRenderedObjectInfoMetric(renderedObjectInfos, frameCount); |
|||
}); |
|||
#endif
|
|||
} |
|||
void Update() |
|||
{ |
|||
RenderTexture.active = renderTexture; |
|||
cpuTexture.ReadPixels(new Rect(Vector2.zero, new Vector2(renderTexture.width, renderTexture.height)), 0, 0); |
|||
RenderTexture.active = null; |
|||
var data = cpuTexture.GetRawTextureData<uint>(); |
|||
ImageReadCallback(Time.frameCount, data, renderTexture); |
|||
|
|||
Vector3 targetPos = transform.worldToLocalMatrix * target.transform.position; |
|||
|
|||
var sensorHandle = GetComponent<PerceptionCamera>().SensorHandle; |
|||
var anno = sensorHandle.ReportAnnotationValues(bbDef, new[] { targetPos }); |
|||
string jsonValues = string.Empty; |
|||
MetricDefinition metricDef = SimulationManager.RegisterMetricDefinition() |
|||
anno.ReportMetric(bbDef, jsonValues); |
|||
|
|||
// if (sensorHandle.ShouldCaptureThisFrame)
|
|||
// {
|
|||
// var anno = sensorHandle.ReportAnnotationValues(bbDef, new[] { targetPos });
|
|||
// }
|
|||
} |
|||
|
|||
void ProduceBoundingBoxesAnnotation(NativeArray<RenderedObjectInfo> renderedObjectInfos, List<LabelEntry> labelingConfigurations, int frameCount) |
|||
{ |
|||
|
|||
|
|||
RenderTextureReader<short>(); |
|||
|
|||
using (s_BoundingBoxCallback.Auto()) |
|||
{ |
|||
var findResult = FindAsyncCaptureInfo(frameCount); |
|||
if (findResult.index == -1) |
|||
return; |
|||
var asyncCaptureInfo = findResult.asyncCaptureInfo; |
|||
var boundingBoxAsyncAnnotation = asyncCaptureInfo.BoundingBoxAsyncMetric; |
|||
if (!boundingBoxAsyncAnnotation.IsValid) |
|||
return; |
|||
|
|||
if (m_BoundingBoxValues == null || m_BoundingBoxValues.Length != renderedObjectInfos.Length) |
|||
m_BoundingBoxValues = new BoundingBoxValue[renderedObjectInfos.Length]; |
|||
|
|||
for (var i = 0; i < renderedObjectInfos.Length; i++) |
|||
{ |
|||
var objectInfo = renderedObjectInfos[i]; |
|||
if (!TryGetLabelEntryFromInstanceId(objectInfo.instanceId, out var labelEntry)) |
|||
continue; |
|||
|
|||
m_BoundingBoxValues[i] = new BoundingBoxValue |
|||
{ |
|||
label_id = labelEntry.id, |
|||
label_name = labelEntry.label, |
|||
instance_id = objectInfo.instanceId, |
|||
x = objectInfo.boundingBox.x, |
|||
y = objectInfo.boundingBox.y, |
|||
width = objectInfo.boundingBox.width, |
|||
height = objectInfo.boundingBox.height, |
|||
}; |
|||
} |
|||
|
|||
boundingBoxAsyncAnnotation.ReportValues(m_BoundingBoxValues); |
|||
} |
|||
} |
|||
|
|||
void ImageReadCallback(int frameCount, NativeArray<uint> data, RenderTexture renderTexture) |
|||
{ |
|||
Debug.Log("Current frame: " + Time.frameCount + ", working frame: " + frameCount); |
|||
|
|||
// First thing lets check that we are the correct frame...
|
|||
if (frameCount == Time.frameCount) |
|||
{ |
|||
Debug.Log("We are operating on the current frame"); |
|||
} |
|||
else |
|||
{ |
|||
Debug.Log("We are on a different frame"); |
|||
} |
|||
} |
|||
} |
|||
#endif
|
撰写
预览
正在加载...
取消
保存
Reference in new issue