From 53466a35b8cf1db191d04a8bdd11f4dda3427a02 Mon Sep 17 00:00:00 2001 From: petpetpeter <55285546+petpetpeter@users.noreply.github.com> Date: Sat, 5 Jun 2021 12:05:47 +0900 Subject: [PATCH 1/5] Add files via upload --- .../Scripts/RawPointCloudGenerator.cs | 271 ++++++++++++++++++ .../Scripts/RawPointCloudGenerator.cs.meta | 11 + 2 files changed, 282 insertions(+) create mode 100644 Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs create mode 100644 Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs.meta diff --git a/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs b/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs new file mode 100644 index 0000000..4c4daef --- /dev/null +++ b/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs @@ -0,0 +1,271 @@ +//----------------------------------------------------------------------- +// +// +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +//----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using GoogleARCore; +using UnityEngine; +using UnityEngine.UI; +/// +/// Computes a point cloud from the depth map on the CPU. +/// +public class RawPointCloudGenerator : MonoBehaviour +{ + /// + /// Type of depth texture to attach to the material. + /// + public bool UseRawDepth = false; + + private const float _maxVisualizationDistanceM = 7; + private const float _minVisualizationDistanceM = 0.4f; + private bool _initialized; + private CameraIntrinsics _cameraIntrinsics; + private Mesh _mesh; + + + //From Blender// + // Limit the number of points to bound the performance cost of rendering the point cloud. + private const int _maxVerticesInBuffer = 1000000; + private const double _maxUpdateInvervalInSeconds = 0.5f; + private const double _minUpdateInvervalInSeconds = 0.07f; + //private static readonly string _confidenceThresholdPropertyName = "_ConfidenceThreshold"; + + + private Vector3[] _vertices = new Vector3[_maxVerticesInBuffer]; + private int _verticesCount = 0; + private int _verticesIndex = 0; + private int[] _indices = new int[_maxVerticesInBuffer]; + private Color32[] _colors = new Color32[_maxVerticesInBuffer]; + + // Buffers that store the color camera image (in YUV420_888 format) each frame. + private byte[] _cameraBufferY; + private byte[] _cameraBufferU; + private byte[] _cameraBufferV; + private int _cameraHeight; + private int _cameraWidth; + private int _pixelStrideUV; + private int _rowStrideY; + private int _rowStrideUV; + private double _updateInvervalInSeconds = _minUpdateInvervalInSeconds; + private double _lastUpdateTimeSeconds; + private Material _pointCloudMaterial; + /// + + /// + /// Computes 3D vertices from the depth map and creates a Mesh() object with the Point primitive + /// type. Each point differently colored based on a depth color ramp. + /// + + public void UpdateRawPointCloud() + { + // Exits when ARCore is not ready. + if (!_initialized || _cameraBufferY == null) + { + return; + } + + // Exits if updating the point cloud too frequently for better performance. + if (Time.realtimeSinceStartup - _lastUpdateTimeSeconds < _updateInvervalInSeconds) + { + return; + } + + + Reset(); //Clear previously create pointcloud + //_pointCloudMaterial.SetFloat(_confidenceThresholdPropertyName, ConfidenceSlider.value); + + // Color and depth images usually have different aspect ratios. The depth image corresponds + // to the region of the camera image that is center-cropped to the depth aspect ratio. + float depthAspectRatio = (float)DepthSource.DepthHeight / DepthSource.DepthWidth; + int colorHeightDepthAspectRatio = (int)(_cameraWidth * depthAspectRatio); + int colorHeightOffset = (_cameraHeight - colorHeightDepthAspectRatio) / 2; + + // Creates point clouds from the depth map. + for (int y = 0; y < DepthSource.DepthHeight; y++) + { + for (int x = 0; x < DepthSource.DepthWidth; x++) + { + int depthIndex = (y * DepthSource.DepthWidth) + x; + float depthInM = (UseRawDepth ? DepthSource.RawDepthArray[depthIndex] : + DepthSource.DepthArray[depthIndex]) * DepthSource.MillimeterToMeter; + float confidence = DepthSource.ConfidenceArray[depthIndex] / 255f; + + // Ignore missing depth values to improve runtime performance. + if (depthInM == 0f || confidence == 0f) + { + continue; + } + + // Computes world-space coordinates. + Vector3 vertex = DepthSource.TransformVertexToWorldSpace( + DepthSource.ComputeVertex(x, y, depthInM)); + + + //Add Color + /*int colorX = x * _cameraWidth / DepthSource.DepthWidth; + int colorY = colorHeightOffset + + (y * colorHeightDepthAspectRatio / DepthSource.DepthHeight); + int linearIndexY = (colorY * _rowStrideY) + colorX; + int linearIndexUV = ((colorY / 2) * _rowStrideUV) + ((colorX / 2) * _pixelStrideUV); + + // Each channel value is an unsigned byte. + byte channelValueY = _cameraBufferY[linearIndexY]; + byte channelValueU = _cameraBufferU[linearIndexUV]; + byte channelValueV = _cameraBufferV[linearIndexUV]; + + byte[] rgb = ConvertYuvToRgb(channelValueY, channelValueU, channelValueV); + byte confidenceByte = (byte)(confidence * 255f); + Color32 color = new Color32(rgb[0], rgb[1], rgb[2], confidenceByte);*/ + float depthRange = _maxVisualizationDistanceM - _minVisualizationDistanceM; + float normalizedDepth = (depthInM - _minVisualizationDistanceM) / depthRange; + Color32 color = ColorRampGenerator.Turbo(normalizedDepth); + + + + if (_verticesCount < _maxVerticesInBuffer - 1) + { + ++_verticesCount; + } + + // Replaces old vertices in the buffer after reaching the maximum capacity. + if (_verticesIndex >= _maxVerticesInBuffer) + { + _verticesIndex = 0; + } + + _vertices[_verticesIndex] = vertex; + _colors[_verticesIndex] = color; + ++_verticesIndex; + } + } + + if (_verticesCount == 0) + { + return; + } + + // Assigns graphical buffers. + + _mesh.SetVertices(_vertices, 0, _verticesCount); + _mesh.SetIndices(_indices, 0, _verticesCount, MeshTopology.Points, 0); + _mesh.SetColors(_colors, 0, _verticesCount); + _mesh.RecalculateBounds(); + + MeshFilter meshFilter = GetComponent(); + meshFilter.mesh = _mesh; + _lastUpdateTimeSeconds = Time.realtimeSinceStartup; + } + + /// + /// Converts a new CPU image into byte buffers and caches to be accessed later. + /// + /// The new CPU image to process. + private void OnImageAvailable(CameraImageBytes image) + { + // Initializes the camera buffer and the composited texture. + if (_cameraBufferY == null || _cameraBufferU == null || _cameraBufferV == null) + { + _cameraWidth = image.Width; + _cameraHeight = image.Height; + _rowStrideY = image.YRowStride; + _rowStrideUV = image.UVRowStride; + _pixelStrideUV = image.UVPixelStride; + _cameraBufferY = new byte[image.Width * image.Height]; + _cameraBufferU = new byte[image.Width * image.Height]; + _cameraBufferV = new byte[image.Width * image.Height]; + } + + // Copies raw data into managed camera buffer. + System.Runtime.InteropServices.Marshal.Copy(image.Y, _cameraBufferY, 0, + image.Height * image.YRowStride); + System.Runtime.InteropServices.Marshal.Copy(image.U, _cameraBufferU, 0, + image.Height * image.UVRowStride / 2); + System.Runtime.InteropServices.Marshal.Copy(image.V, _cameraBufferV, 0, + image.Height * image.UVRowStride / 2); + } + + private byte[] ConvertYuvToRgb(byte y, byte u, byte v) + { + // See https://en.wikipedia.org/wiki/YUV. + float yFloat = y / 255.0f; // Range [0.0, 1.0]. + float uFloat = (u * 0.872f / 255.0f) - 0.436f; // Range [-0.436, 0.436]. + float vFloat = (v * 1.230f / 255.0f) - 0.615f; // Range [-0.615, 0.615]. + float rFloat = Mathf.Clamp01(yFloat + (1.13983f * vFloat)); + float gFloat = Mathf.Clamp01(yFloat - (0.39465f * uFloat) - (0.58060f * vFloat)); + float bFloat = Mathf.Clamp01(yFloat + (2.03211f * uFloat)); + byte r = (byte)(rFloat * 255f); + byte g = (byte)(gFloat * 255f); + byte b = (byte)(bFloat * 255f); + return new[] { r, g, b }; + } + + public void Reset() + { + _verticesCount = 0; + _verticesIndex = 0; + } + + private void Start() + { + _mesh = new Mesh(); + _mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; + _pointCloudMaterial = GetComponent().material; + + // Sets the index buffer. + for (int i = 0; i < _maxVerticesInBuffer; ++i) + { + _indices[i] = i; + } + + Reset(); + } + + private void Update() + { + // Waits until Depth API is initialized. + if (!_initialized && DepthSource.Initialized) + { + _initialized = true; + } + + if (DepthSource.NewRawDepthAvailable) + { + // Fetches CPU image. + using (var image = Frame.CameraImage.AcquireCameraImageBytes()) + { + if (!image.IsAvailable) + { + return; + } + + OnImageAvailable(image); + } + + //UpdateRawPointCloud(); + } + + /*transform.position = Camera.main.transform.forward * OffsetFromCamera; + float normalizedDeltaTime = Mathf.Clamp01( + (float)(Time.deltaTime - _minUpdateInvervalInSeconds)); + _updateInvervalInSeconds = Mathf.Lerp((float)_minUpdateInvervalInSeconds, + (float)_maxUpdateInvervalInSeconds, + normalizedDeltaTime);*/ + } +} diff --git a/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs.meta b/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs.meta new file mode 100644 index 0000000..9492b63 --- /dev/null +++ b/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91a2c44af012e4c02ac317054e2838bb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From f0b373804f842e157e3d1c915bc108a929f6b6d9 Mon Sep 17 00:00:00 2001 From: petpetpeter <55285546+petpetpeter@users.noreply.github.com> Date: Sat, 5 Jun 2021 12:07:07 +0900 Subject: [PATCH 2/5] Add files via upload --- .../Scenes/PointCloudWithRawDepth.unity | 621 ++++++++++++++++++ .../Scenes/PointCloudWithRawDepth.unity.meta | 7 + 2 files changed, 628 insertions(+) create mode 100644 Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity create mode 100644 Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity.meta diff --git a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity new file mode 100644 index 0000000..cbfd53f --- /dev/null +++ b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity @@ -0,0 +1,621 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &128069680 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 128069684} + - component: {fileID: 128069682} + - component: {fileID: 128069681} + - component: {fileID: 128069683} + - component: {fileID: 128069685} + m_Layer: 0 + m_Name: Point cloud from CPU depth data + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!33 &128069681 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 128069680} + m_Mesh: {fileID: 0} +--- !u!23 &128069682 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 128069680} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 095393401fd0e48c2b3665c05b290e5a, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!114 &128069683 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 128069680} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 91a2c44af012e4c02ac317054e2838bb, type: 3} + m_Name: + m_EditorClassIdentifier: + UseRawDepth: 1 +--- !u!4 &128069684 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 128069680} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &128069685 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 128069680} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e42a5dba022f44d2bbcd45b3a1eb5125, type: 3} + m_Name: + m_EditorClassIdentifier: + UseRawDepth: 1 + SetAsMainTexture: 0 + DepthTargetMaterial: {fileID: 0} +--- !u!1 &764884809 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 764884810} + - component: {fileID: 764884813} + - component: {fileID: 764884812} + - component: {fileID: 764884811} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &764884810 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 764884809} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1809696643} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &764884811 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 764884809} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c93ea1dce8251406ea4fe678225de108, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &764884812 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 764884809} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: 50a50753ba3b4487e93b75cafa4a9518, type: 3} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Update +--- !u!222 &764884813 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 764884809} + m_CullTransparentMesh: 0 +--- !u!1001 &1039285601 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354488, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5734534533885354492, guid: 9b04b7d0c1be3426585838493f60c53b, + type: 3} + propertyPath: m_Name + value: DepthARComponents + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 9b04b7d0c1be3426585838493f60c53b, type: 3} +--- !u!1 &1421493915 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1421493919} + - component: {fileID: 1421493918} + - component: {fileID: 1421493917} + - component: {fileID: 1421493916} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1421493916 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1421493915} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1421493917 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1421493915} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 2 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &1421493918 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1421493915} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 50 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 25 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1421493919 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1421493915} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1809696643} + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &1809696639 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1809696643} + - component: {fileID: 1809696642} + - component: {fileID: 1809696641} + - component: {fileID: 1809696640} + m_Layer: 5 + m_Name: Update Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1809696640 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1809696639} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Highlighted + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1809696641} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 128069683} + m_MethodName: UpdateRawPointCloud + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &1809696641 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1809696639} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.7058824} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 50e4e9aed7b514a84becc51889a80b1c, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1809696642 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1809696639} + m_CullTransparentMesh: 0 +--- !u!224 &1809696643 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1809696639} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 764884810} + m_Father: {fileID: 1421493919} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: -33, y: 24} + m_SizeDelta: {x: 66, y: 44} + m_Pivot: {x: 0, y: 0} diff --git a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity.meta b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity.meta new file mode 100644 index 0000000..e234f39 --- /dev/null +++ b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 008ed2ce099c346a3a90fc6b07347ae3 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From d8a56b4d2794d9a3de033476b41ecc11519f5d7d Mon Sep 17 00:00:00 2001 From: petpetpeter Date: Sat, 12 Jun 2021 11:59:34 +0900 Subject: [PATCH 3/5] Change Script Reference --- .../PointCloud/Scenes/PointCloudWithRawDepth.unity | 2 +- .../PointCloud/Scenes/PointCloudWithRawDepth.unity.meta | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity index cbfd53f..2c00570 100644 --- a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity +++ b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity @@ -197,7 +197,7 @@ MonoBehaviour: m_GameObject: {fileID: 128069680} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 91a2c44af012e4c02ac317054e2838bb, type: 3} + m_Script: {fileID: 11500000, guid: b967b52f7d77f5f41804d82bd82271ea, type: 3} m_Name: m_EditorClassIdentifier: UseRawDepth: 1 diff --git a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity.meta b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity.meta index e234f39..eca6e06 100644 --- a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity.meta +++ b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 008ed2ce099c346a3a90fc6b07347ae3 +guid: 275c3cbd6d1ab6c4ea896228f281bf00 DefaultImporter: externalObjects: {} userData: From 3b72f3d9f70975df8b3d36f741d4eac69506a4ed Mon Sep 17 00:00:00 2001 From: petpetpeter Date: Sat, 12 Jun 2021 12:18:20 +0900 Subject: [PATCH 4/5] Update Referencing --- .../PointCloud/Scenes/PointCloudWithRawDepth.unity | 2 +- .../PointCloud/Scripts/PointCloudGenerator.cs.meta | 2 +- .../PointCloud/Scripts/RawPointCloudGenerator.cs.meta | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity index 2c00570..8839de1 100644 --- a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity +++ b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloudWithRawDepth.unity @@ -197,7 +197,7 @@ MonoBehaviour: m_GameObject: {fileID: 128069680} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: b967b52f7d77f5f41804d82bd82271ea, type: 3} + m_Script: {fileID: 11500000, guid: 79e874a0ad35b9d418b287356194f877, type: 3} m_Name: m_EditorClassIdentifier: UseRawDepth: 1 diff --git a/Assets/ARRealismDemos/PointCloud/Scripts/PointCloudGenerator.cs.meta b/Assets/ARRealismDemos/PointCloud/Scripts/PointCloudGenerator.cs.meta index 642b400..030fcfe 100644 --- a/Assets/ARRealismDemos/PointCloud/Scripts/PointCloudGenerator.cs.meta +++ b/Assets/ARRealismDemos/PointCloud/Scripts/PointCloudGenerator.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 91a2c44af012e4c02ac317054e2838bb +guid: 4ddbac5279728a64bb6a44ffbd13f993 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs.meta b/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs.meta index 9492b63..dab4202 100644 --- a/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs.meta +++ b/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 91a2c44af012e4c02ac317054e2838bb +guid: 79e874a0ad35b9d418b287356194f877 MonoImporter: externalObjects: {} serializedVersion: 2 From 5d2f4604553d9bfc27ec0db678645a06b4e077f1 Mon Sep 17 00:00:00 2001 From: petpetpeter Date: Sat, 12 Jun 2021 12:46:51 +0900 Subject: [PATCH 5/5] only ignore 0 confidence pixel in Raw Depth Mode --- Assets/ARRealismDemos/PointCloud/Scenes/PointCloud.unity | 4 ++-- .../PointCloud/Scripts/RawPointCloudGenerator.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloud.unity b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloud.unity index 2d78e7c..e565240 100644 --- a/Assets/ARRealismDemos/PointCloud/Scenes/PointCloud.unity +++ b/Assets/ARRealismDemos/PointCloud/Scenes/PointCloud.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -196,7 +196,7 @@ MonoBehaviour: m_GameObject: {fileID: 128069680} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 91a2c44af012e4c02ac317054e2838bb, type: 3} + m_Script: {fileID: 11500000, guid: 4ddbac5279728a64bb6a44ffbd13f993, type: 3} m_Name: m_EditorClassIdentifier: UseRawDepth: 0 diff --git a/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs b/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs index 4c4daef..47c4e9f 100644 --- a/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs +++ b/Assets/ARRealismDemos/PointCloud/Scripts/RawPointCloudGenerator.cs @@ -107,8 +107,8 @@ public void UpdateRawPointCloud() DepthSource.DepthArray[depthIndex]) * DepthSource.MillimeterToMeter; float confidence = DepthSource.ConfidenceArray[depthIndex] / 255f; - // Ignore missing depth values to improve runtime performance. - if (depthInM == 0f || confidence == 0f) + // Ignore missing depth values to improve runtime performance. //Only for raw depth + if ((depthInM == 0f || confidence == 0f) && UseRawDepth) { continue; }