void Unitialize() { if (this.reader != null) { // BodyFrameReder is IDisposable this.reader.Dispose(); this.reader = null; } // Body is IDisposable if (this.bodies != null) { bodies = null; //foreach (Body body in this.bodies) //{ // if (body != null) // { // body.Dispose(); // } //} } if (this.sensor != null) { this.sensor.Close(); this.sensor = null; } if (gestureController != null) { gestureController.GestureRecognized -= OnGestureRecognized; gestureController = null; } }
void Initialize() { if (this.sensor != null) { // open the sensor this.sensor.Open(); //bodies = new Body[sensor.BodyFrameSource.BodyCount]; // open the reader for the body frames reader = sensor.BodyFrameSource.OpenReader(); if (this.reader != null) { this.reader.FrameArrived += this.sensor_SkeletonFrameReady; } KinectConnectionState = "Connected"; // add timer for clearing last detected gesture _clearTimer = new Timer(2000); _clearTimer.Elapsed += new ElapsedEventHandler(clearTimer_Elapsed); // initialize the gesture recognizer gestureController = new GestureController(); gestureController.GestureRecognized += OnGestureRecognized; // register the gestures for this demo RegisterGestures(); } }