void Start() { itemManager = GetComponent <ItemManager>(); webcam = GetComponent <HololensCameraUWP>(); faceRenderer = GetComponent <FaceRenderer>(); faceRenderer.SetWebcam(webcam); localFaceTracker = new LocalFaceTracker(LocalTrackerNumberOfIters, LocalTrackerConfidenceThreshold); backendFaceTracker = new BackendFaceTracker(nLandmarks, BackendTrackerConfidenceThreshold, 43002, localFaceTracker); if (PhraseRecognitionSystem.isSupported) { keywordCollection = new Dictionary <string, KeywordAction>(); keywordCollection.Add("Show debug", ShowDebug); keywordCollection.Add("Hide debug", HideDebug); keywordCollection.Add("Computer", BackendProcessing); keywordCollection.Add("Local", LocalProcessing); keywordCollection.Add("Show face", ShowFace); keywordCollection.Add("Hide face", HideFace); keywordRecognizer = new KeywordRecognizer(keywordCollection.Keys.ToArray()); keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized; keywordRecognizer.Start(); } if (FPSText != null) { FPSText.text = ""; } }
private PXCMFaceModule faceAnalyzer; //FaceModule Instance /// <summary> /// Use this for initialization /// Unity function called on the frame when a script is enabled /// just before any of the Update methods is called the first time. /// </summary> void Start() { faceRenderer = gameObject.GetComponent <FaceRenderer>(); /* Initialize a PXCMSenseManager instance */ psm = PXCMSenseManager.CreateInstance(); if (psm == null) { Debug.LogError("SenseManager Initialization Failed"); return; } /* Enable the color stream of size 640x480 */ psm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480); /* Enable the face tracking module*/ sts = psm.EnableFace(); if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) { Debug.LogError("PXCSenseManager.EnableFace: " + sts); } /* Retrieve an instance of face to configure */ faceAnalyzer = psm.QueryFace(); if (faceAnalyzer == null) { Debug.LogError("PXCSenseManager.QueryFace"); } /* Initialize the execution pipeline */ sts = psm.Init(); if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) { Debug.LogError("PXCMSenseManager.Init Failed"); OnDisable(); return; } /* Retrieve a PXCMFaceConfiguration instance from a face to enable Gestures and Alerts */ PXCMFaceConfiguration config = faceAnalyzer.CreateActiveConfiguration(); config.detection.isEnabled = true; // 3D detection is the default tracking mode. config.landmarks.isEnabled = true; config.pose.isEnabled = true; config.QueryExpressions().Enable(); config.QueryExpressions().EnableExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_MOUTH_OPEN); config.EnableAllAlerts(); config.ApplyChanges(); config.Dispose(); }