Esempio n. 1
0
        /// <summary>
        /// Closes the connection to this Kinect device
        /// </summary>
        public void Close()
        {
            // Stop Cameras
            if (this.VideoCamera.IsRunning)
            {
                this.VideoCamera.Stop();
            }
            if (this.DepthCamera.IsRunning)
            {
                this.DepthCamera.Stop();
            }

            // Close device
            int result = KinectNative.freenect_close_device(this.devicePointer);

            if (result != 0)
            {
                throw new Exception("Could not close connection to Kinect Device (ID=" + this.DeviceID + "). Error Code = " + result);
            }

            // Dispose of child instances
            this.LED           = null;
            this.Motor         = null;
            this.Accelerometer = null;
            this.VideoCamera   = null;
            this.DepthCamera   = null;

            // Unegister the device
            KinectNative.UnregisterDevice(this.devicePointer);

            // Not open anymore
            this.IsOpen = false;
        }