public NiteGUI(NiteController niteController) { //depth_Thread = new Thread(new ThreadStart(this.updateusermap)); //image_Thread = new Thread(new ThreadStart(this.updatergbimage)); //depth_Thread.Start(); //image_Thread.Start(); this.niteController = niteController; // // Setting the Kinect in certain angle // this.startAngle = 2000; // this.kinectDevice = new CLNUIDevice(startAngle); // // Init depth & label map related stuff usersMapSize = NiteWrapper.GetDepthWidth() * NiteWrapper.GetDepthHeight(); usersLblTex = new Texture2D(NiteWrapper.GetDepthWidth(), NiteWrapper.GetDepthHeight()); usersMapColors = new Color[usersMapSize]; usersMapRect = new Rect(Screen.width - usersLblTex.width / 2, Screen.height - usersLblTex.height / 2, usersLblTex.width / 2, usersLblTex.height / 2); usersLabelMap = new short[usersMapSize]; usersDepthMap = new short[usersMapSize]; usersHistogramMap = new float[5000]; // Init camera image stuff RGBwidth = NiteWrapper.getRGBWidth(); RGBheight = NiteWrapper.getRGBHeight(); image = new short[RGBwidth * RGBheight * 3]; usersImageTex = new Texture2D(RGBwidth, RGBheight); usersImageColors = new Color[usersMapSize]; usersImageRect = new Rect(Screen.width - usersImageTex.width / 2, Screen.height - usersImageTex.height / 2, usersImageTex.width / 2, usersImageTex.height / 2); bg = GameObject.Find("Background Image").GetComponent <GUITexture>(); bg.pixelInset = new Rect(-Screen.width / 2, -Screen.height / 2, Screen.width, Screen.height); stateIcon = Resources.Load("lookingUser") as Texture2D; }
void Start() { uint rc = NiteWrapper.Init(new StringBuilder(".\\OpenNI.xml")); if (rc != 0) { Debug.Log(String.Format("Error initing OpenNI: {0}", Marshal.PtrToStringAnsi(NiteWrapper.GetStatusString(rc)))); } // Init depth & label map related stuff usersMapSize = NiteWrapper.GetDepthWidth() * NiteWrapper.GetDepthHeight(); usersLblTex = new Texture2D(NiteWrapper.GetDepthWidth(), NiteWrapper.GetDepthHeight()); usersMapColors = new Color[usersMapSize]; usersMapRect = new Rect(Screen.width - usersLblTex.width / 2, Screen.height - usersLblTex.height / 2, usersLblTex.width / 2, usersLblTex.height / 2); usersLabelMap = new short[usersMapSize]; usersDepthMap = new short[usersMapSize]; usersHistogramMap = new float[5000]; // text caption = GameObject.Find("GUI Text").guiText; // init our avatar controllers soldiers = new SoldierAvatar[2]; soldiers[0] = new SoldierAvatar(GameObject.Find("Soldier1")); //soldiers[1] = new SoldierAvatar(GameObject.Find("Soldier2")); // This line was removed so we can have 1 soldier without errors // init user lists - one will contain all users, the second will contain only calibrated & mapped users allUsers = new List <uint>(); calibratedUsers = new Dictionary <uint, SoldierAvatar>(); // init user callbacks NewUser = new NiteWrapper.UserDelegate(OnNewUser); CalibrationStarted = new NiteWrapper.UserDelegate(OnCalibrationStarted); CalibrationFailed = new NiteWrapper.UserDelegate(OnCalibrationFailed); CalibrationSuccess = new NiteWrapper.UserDelegate(OnCalibrationSuccess); UserLost = new NiteWrapper.UserDelegate(OnUserLost); // Start looking NiteWrapper.StartLookingForUsers(NewUser, CalibrationStarted, CalibrationFailed, CalibrationSuccess, UserLost); Debug.Log("Waiting for users to calibrate"); // set default smoothing NiteWrapper.SetSkeletonSmoothing(0.6); }