void StartFacetracker() { try { if (debugText != null) { debugText.GetComponent <GUIText>().text = "Please, wait..."; } // initialize Kinect sensor as needed int rc = FacetrackingWrapper.InitKinectSensor((int)FacetrackingWrapper.Constants.ColorImageResolution, (int)FacetrackingWrapper.Constants.DepthImageResolution, FacetrackingWrapper.Constants.IsNearMode); if (rc != 0) { throw new Exception("Initialization of Kinect sensor failed"); } // Initialize the kinect speech wrapper rc = FacetrackingWrapper.InitFaceTracking(); if (rc < 0) { throw new Exception(String.Format("Error initializing Kinect/FT: hr=0x{0:X}", rc)); } if (ComputeColorMap) { // Initialize color map related stuff usersClrTex = new Texture2D(FacetrackingWrapper.GetImageWidth(), FacetrackingWrapper.GetImageHeight(), TextureFormat.ARGB32, false); usersClrRect = new Rect(Screen.width, Screen.height - usersClrTex.height, -usersClrTex.width, usersClrTex.height); colorImage = new Color32[FacetrackingWrapper.GetImageWidth() * FacetrackingWrapper.GetImageHeight()]; videoBuffer = new byte[FacetrackingWrapper.GetImageWidth() * FacetrackingWrapper.GetImageHeight() * 4]; } instance = this; facetrackingInitialized = true; DontDestroyOnLoad(gameObject); if (debugText != null) { debugText.GetComponent <GUIText>().text = "Ready."; } } catch (DllNotFoundException ex) { Debug.LogError(ex.ToString()); if (debugText != null) { debugText.GetComponent <GUIText>().text = "Please check the Kinect and FT-Library installations."; } } catch (Exception ex) { Debug.LogError(ex.ToString()); if (debugText != null) { debugText.GetComponent <GUIText>().text = ex.Message; } } }