浏览代码

Adding code to display the estimated body height scale factor.

/3.1
Todd Stinson 5 年前
当前提交
46afd02c
共有 3 个文件被更改,包括 284 次插入5 次删除
  1. 202
      Assets/Scenes/HumanSegmentation/HumanBodyTracking3D.unity
  2. 76
      Assets/Scripts/TestBodyAnchorScale.cs
  3. 11
      Assets/Scripts/TestBodyAnchorScale.cs.meta

202
Assets/Scenes/HumanSegmentation/HumanBodyTracking3D.unity


m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_TrainingDataDestination: TrainingData
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4

m_EditorClassIdentifier:
m_UseCustomMaterial: 0
m_CustomMaterial: {fileID: 0}
m_UseCustomRendererAsset: 0
m_CustomRendererAsset: {fileID: 0}
--- !u!20 &282840813
Camera:
m_ObjectHideFlags: 0

m_GameObject: {fileID: 1148677825}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal

m_GameObject: {fileID: 1148677825}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}

m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1192323206
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1192323210}
- component: {fileID: 1192323209}
- component: {fileID: 1192323208}
- component: {fileID: 1192323207}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1192323207
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1192323206}
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 &1192323208
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1192323206}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &1192323209
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1192323206}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &1192323210
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1192323206}
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: 1427795753}
m_Father: {fileID: 0}
m_RootOrder: 5
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 &1335839533
GameObject:
m_ObjectHideFlags: 0

m_EditorClassIdentifier:
m_HumanBodyPose2DEstimationEnabled: 0
m_HumanBodyPose3DEstimationEnabled: 1
m_HumanBodyPose3DScaleEstimationEnabled: 1
--- !u!1 &1427795752
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1427795753}
- component: {fileID: 1427795755}
- component: {fileID: 1427795754}
m_Layer: 5
m_Name: Height Scale Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1427795753
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1427795752}
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: 1192323210}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.8}
m_AnchorMax: {x: 0.5, y: 0.8}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 800, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1427795754
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1427795752}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 60
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 60
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: <no scale>
--- !u!222 &1427795755
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1427795752}
m_CullTransparentMesh: 0
--- !u!1 &1959473036
GameObject:
m_ObjectHideFlags: 0

m_Component:
- component: {fileID: 1959473038}
- component: {fileID: 1959473039}
- component: {fileID: 1959473037}
m_Layer: 0
m_Name: Human Body Tracking
m_TagString: Untagged

m_IsActive: 1
--- !u!114 &1959473037
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1959473036}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f7a99cf97577b431494054a0b0e5f423, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HumanBodyManager: {fileID: 1335839536}
m_ImageInfo: {fileID: 1427795754}
--- !u!4 &1959473038
Transform:
m_ObjectHideFlags: 0

76
Assets/Scripts/TestBodyAnchorScale.cs


using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
public class TestBodyAnchorScale : MonoBehaviour
{
[SerializeField]
[Tooltip("The ARHumanBodyManager which will produce frame events.")]
ARHumanBodyManager m_HumanBodyManager;
/// <summary>
/// Get or set the <c>ARHumanBodyManager</c>.
/// </summary>
public ARHumanBodyManager humanBodyManager
{
get { return m_HumanBodyManager; }
set { m_HumanBodyManager = value; }
}
[SerializeField]
Text m_ImageInfo;
/// <summary>
/// The UI Text used to display information about the image on screen.
/// </summary>
public Text imageInfo
{
get { return m_ImageInfo; }
set { m_ImageInfo = value; }
}
void OnEnable()
{
Debug.Assert(m_ImageInfo != null, "need a text field");
m_ImageInfo.enabled = true;
Debug.Assert(m_HumanBodyManager != null, "Human body manager is required.");
m_HumanBodyManager.humanBodiesChanged += OnHumanBodiesChanged;
}
void OnDisable()
{
Debug.Assert(m_ImageInfo != null, "need a text field");
m_ImageInfo.enabled = false;
Debug.Assert(m_HumanBodyManager != null, "Human body manager is required.");
m_HumanBodyManager.humanBodiesChanged -= OnHumanBodiesChanged;
}
void OnHumanBodiesChanged(ARHumanBodiesChangedEventArgs eventArgs)
{
bool hasScale = false;
float scale = 0.0f;
foreach (var humanBody in eventArgs.added)
{
if (!hasScale)
{
scale = humanBody.estimatedHeightScaleFactor;
hasScale = true;
}
}
foreach (var humanBody in eventArgs.updated)
{
if (!hasScale)
{
scale = humanBody.estimatedHeightScaleFactor;
hasScale = true;
}
}
Debug.Assert(m_ImageInfo != null, "need a text field");
m_ImageInfo.text = hasScale ? scale.ToString("F10") : "<no scale>";
}
}

11
Assets/Scripts/TestBodyAnchorScale.cs.meta


fileFormatVersion: 2
guid: f7a99cf97577b431494054a0b0e5f423
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存