t1 / TFDContents / Assets / KinectScripts / Samples / GetFaceSmileStatus.cs @ 3
이력 | 보기 | 이력해설 | 다운로드 (1.65 KB)
| 1 | 3 | KTH | #if !(UNITY_WSA_10_0 && NETFX_CORE) |
|---|---|---|---|
| 2 | using UnityEngine; |
||
| 3 | using System.Collections; |
||
| 4 | |||
| 5 | public class GetFaceSmileStatus : MonoBehaviour |
||
| 6 | {
|
||
| 7 | |||
| 8 | [Tooltip("Index of the player, tracked by this component. 0 means the 1st player, 1 - the 2nd one, 2 - the 3rd one, etc.")]
|
||
| 9 | public int playerIndex = 0; |
||
| 10 | |||
| 11 | [Tooltip("GUI-Text to display the FT-manager debug messages.")]
|
||
| 12 | public GUIText debugText; |
||
| 13 | |||
| 14 | [Tooltip("Currently detected smile status.")]
|
||
| 15 | public Windows.Kinect.DetectionResult smileStatus = Windows.Kinect.DetectionResult.Unknown; |
||
| 16 | |||
| 17 | |||
| 18 | private KinectManager kinectManager; |
||
| 19 | private KinectInterop.SensorData sensorData; |
||
| 20 | |||
| 21 | |||
| 22 | void Start () |
||
| 23 | {
|
||
| 24 | kinectManager = KinectManager.Instance; |
||
| 25 | |||
| 26 | if (kinectManager != null) |
||
| 27 | {
|
||
| 28 | sensorData = kinectManager.GetSensorData (); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | |||
| 33 | void Update () |
||
| 34 | {
|
||
| 35 | if (kinectManager == null || sensorData == null || sensorData.sensorInterface == null) |
||
| 36 | return; |
||
| 37 | |||
| 38 | long userId = kinectManager.GetUserIdByIndex (playerIndex); |
||
| 39 | Kinect2Interface k2int = (Kinect2Interface)sensorData.sensorInterface; |
||
| 40 | |||
| 41 | for (int i = 0; i < sensorData.bodyCount; i++) |
||
| 42 | {
|
||
| 43 | if(k2int.faceFrameSources != null && k2int.faceFrameSources[i] != null && k2int.faceFrameSources[i].TrackingId == (ulong)userId) |
||
| 44 | {
|
||
| 45 | if(k2int.faceFrameResults != null && k2int.faceFrameResults[i] != null) |
||
| 46 | {
|
||
| 47 | Windows.Kinect.DetectionResult newStatus = k2int.faceFrameResults [i].FaceProperties [Microsoft.Kinect.Face.FaceProperty.Happy]; |
||
| 48 | |||
| 49 | if (newStatus != Windows.Kinect.DetectionResult.Unknown) |
||
| 50 | {
|
||
| 51 | smileStatus = newStatus; |
||
| 52 | } |
||
| 53 | |||
| 54 | debugText.text = "Smile-status: " + smileStatus; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | } |
||
| 60 | |||
| 61 | } |
||
| 62 | #endif |