void Update() { if (!manager) { manager = KinectManager.Instance; } if (!faceManager) { faceManager = FacetrackingManager.Instance; } // get the face points if (manager != null && manager.IsInitialized() && faceManager && faceManager.IsFaceTrackingInitialized()) { long userId = manager.GetUserIdByIndex(playerIndex); if (userId == 0) { return; } if (faceVertices == null) { int iVertCount = faceManager.GetUserFaceVertexCount(userId); if (iVertCount > 0) { faceVertices = new Vector3[iVertCount]; } } if (faceVertices != null) { if (faceManager.GetUserFaceVertices(userId, ref faceVertices)) { if (faceVertices != null && faceVertices[(int)facePoint] != Vector3.zero) { Vector3 facePointPos = faceVertices [(int)facePoint]; if (foregroundCamera) { facePointPos = GetOverlayPosition(facePointPos); } if (facePointTransform) { facePointTransform.position = facePointPos; } if (faceInfoText) { string sStatus = string.Format("{0}: {1}", facePoint, facePointPos); faceInfoText.text = sStatus; } } } } } }
void Update() { if (!manager) { manager = KinectManager.Instance; } if (!faceManager) { faceManager = FacetrackingManager.Instance; } // // get reference to the Kinect2Interface // if(k2interface == null) // { // manager = KinectManager.Instance; // // if(manager && manager.IsInitialized()) // { // KinectInterop.SensorData sensorData = manager.GetSensorData(); // // if(sensorData != null && sensorData.sensorInterface != null) // { // k2interface = (Kinect2Interface)sensorData.sensorInterface; // } // } // } // get the face points if (manager != null && manager.IsInitialized() && faceManager && faceManager.IsFaceTrackingInitialized()) { long userId = manager.GetUserIdByIndex(playerIndex); if (faceVertices == null) { int iVertCount = faceManager.GetUserFaceVertexCount(userId); if (iVertCount > 0) { faceVertices = new Vector3[iVertCount]; } } if (faceVertices != null) { if (faceManager.GetUserFaceVertices(userId, ref faceVertices)) { Matrix4x4 kinectToWorld = manager.GetKinectToWorldMatrix(); HighDetailFacePoints[] facePoints = (HighDetailFacePoints[])System.Enum.GetValues(typeof(HighDetailFacePoints)); for (int i = 0; i < facePoints.Length; i++) { HighDetailFacePoints point = facePoints[i]; dictFacePoints[point] = kinectToWorld.MultiplyPoint3x4(faceVertices[(int)point]); } } } } if (faceVertices != null && faceVertices[(int)facePoint] != Vector3.zero) { Vector3 facePointPos = faceVertices [(int)facePoint]; if (facePointTransform) { facePointTransform.position = facePointPos; } if (faceInfoText) { string sStatus = string.Format("{0}: {1}", facePoint, facePointPos); faceInfoText.text = sStatus; } } }