/// <summary>
        /// Close opened reader and sensors.
        /// </summary>
        public void Close()
        {
            if (_multiFrameReader != null)
            {
                _multiFrameReader.MultiSourceFrameArrived -= MultiFrameArrived;
                _multiFrameReader.Dispose();
                _multiFrameReader = null;
            }

            if (_colorFrameReader != null)
            {
                _colorFrameReader.FrameArrived -= ColorFrameArrived;
                _colorFrameReader.Dispose();
                _colorFrameReader = null;
            }

            if (_bodyFrameReader != null)
            {
                _bodyFrameReader.FrameArrived -= BodyFrameArrived;
                _bodyFrameReader.Dispose();
                _bodyFrameReader = null;
            }

            if (!_kinectUsedExternally)
            {
                _kinectSensor?.Close();
            }
        }
Esempio n. 2
0
    void OnDestroy()
    {
        bodyFrameReader?.Dispose();
        bodyFrameReader = null;

        kinect?.Close();
        kinect = null;
    }
Esempio n. 3
0
 public void Close()
 {
     bfReader?.Dispose();
     try {
         kSensor?.Close();
     } catch { }
     if (kinect != null)
     {
         kinect = null;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Execute shutdown tasks
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void MainWindow_Closing(object sender, CancelEventArgs e)
        {
            _bodyDriver?.Dispose();
            _bodyDriver = null;

            _colorDriver?.Dispose();
            _colorDriver = null;

            _infraredDriver?.Dispose();
            _infraredDriver = null;

            kinectSensor?.Close();
            kinectSensor = null;
        }
Esempio n. 5
0
    void OnApplicationQuit()
    {
        if (bodyReader != null)
        {
            bodyReader.Dispose();
        }

        if (colorReader != null)
        {
            colorReader.Dispose();
        }


        if (sensor != null && sensor.IsOpen)
        {
            sensor.Close();
        }
    }
Esempio n. 6
0
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     // after the window is closed dispose the framereade and close the kinect sensor
     confMat.Close();
     if (depthFrameReader != null)
     {
         depthFrameReader.Dispose();
         depthFrameReader = null;
     }
     if (kinectSensor != null)
     {
         kinectSensor.Close();
         kinectSensor = null;
     }
     bckgroundworker1.CancelAsync();
     Rendering.Dispose();
     Rendering.CancelAsync();
 }
Esempio n. 7
0
    void OnApplicationQuit()
    {
        if (_bodyFrameReader != null)
        {
            _bodyFrameReader.Dispose();
            _bodyFrameReader = null;
        }

        if (_sensor != null)
        {
            if (_sensor.IsOpen)
            {
                _sensor.Close();
            }

            _sensor = null;
        }
    }
    //結束的時候關閉KINECT。
    public void Shutdown()
    {
        if (_Reader != null)
        {
            _Reader.Dispose();
            _Reader = null;
        }

        if (_Sensor != null)
        {
            if (_Sensor.IsOpen)
            {
                _Sensor.Close();
            }

            _Sensor = null;
        }
    }
Esempio n. 9
0
    void OnApplicationQuit()
    {
        //Close the depth reader
        if (depthReader != null)
        {
            depthReader.Dispose();
        }

        //Close the sensor
        if (sensor != null && sensor.IsOpen)
        {
            sensor.Close();
        }

        //Close buffers
        outBuffer.Dispose();
        depthComputeBuffer.Dispose();
    }
Esempio n. 10
0
    private void OnDestroy()
    {
        if (_Reader != null)
        {
            _Reader.Dispose();
            _Reader = null;
        }

        if (_Sensor != null)
        {
            if (_Sensor.IsOpen)
            {
                _Sensor.Close();
            }

            _Sensor = null;
        }
    }
        public void CloseSensorAndReader()
        {
            if (reader != null)
            {
                reader.Dispose();
                reader = null;
            }

            if (sensor != null)
            {
                if (sensor.IsOpen)
                {
                    sensor.Close();
                }

                sensor = null;
            }
        }
Esempio n. 12
0
        void OnApplicationQuit()
        {
            if (_Reader != null)
            {
                _Reader.Dispose();
                _Reader = null;
            }

            if (_Sensor != null)
            {
                if (_Sensor.IsOpen)
                {
                    _Sensor.Close();
                }

                _Sensor = null;
            }
        }
        public void Dispose()
        {
            if (bodyFrameReader != null)
            {
                bodyFrameReader.Dispose();
            }

            if (sensor != null && sensor.IsOpen)
            {
                sensor.Close();
            }

            if (trafficLightSerialPort != null && trafficLightSerialPort.IsOpen)
            {
                trafficLightSerialPort.Close();
                trafficLightSerialPort.Dispose();
            }
        }
Esempio n. 14
0
    void OnApplicationQuit()
    {
        if (bodyFrameReader != null)
        {
            bodyFrameReader.Dispose();
            bodyFrameReader = null;
        }

        if (kinectSensor != null)
        {
            if (kinectSensor.IsOpen)
            {
                kinectSensor.Close();
            }

            kinectSensor = null;
        }
    }
    void OnApplicationQuit()
    {
        if (i_reader != null)
        {
            i_reader.Dispose();
            i_reader = null;
        }

        if (i_sensor != null)
        {
            if (i_sensor.IsOpen)
            {
                i_sensor.Close();
            }

            i_sensor = null;
        }
    }
            private void OnApplicationQuit()
            {
                if (frameReader != null)
                {
                    frameReader.Dispose();
                    frameReader = null;
                }

                if (kinectSensor != null)
                {
                    if (kinectSensor.IsOpen)
                    {
                        kinectSensor.Close();
                    }

                    kinectSensor = null;
                }
            }
Esempio n. 17
0
 void MainPage_Unloaded(object sender, RoutedEventArgs e)
 {
     if (irReader != null)
     {
         irReader.Dispose();
         irReader = null;
     }
     if (msfr != null)
     {
         msfr.Dispose();
         msfr = null;
     }
     if (ksensor != null)
     {
         ksensor.Close();
         ksensor = null;
     }
 }
Esempio n. 18
0
        public static void ShutdownKinect()
        {
            if (kinectReader != null)
            {
                kinectReader.Dispose();
                kinectReader = null;
            }

            if (kinectSensor != null)
            {
                if (kinectSensor.IsOpen)
                {
                    kinectSensor.Close();
                }

                kinectSensor = null;
            }
        }
Esempio n. 19
0
    void OnApplicationQuit()
    {
        if (reader != null)
        {
            reader.Dispose();
            reader = null;
        }

        if (sensor != null)
        {
            if (sensor.IsOpen)
            {
                sensor.Close();
            }

            sensor = null;
        }
    }
    /// <summary>
    /// Called when Unity application or build program is closed.
    ///
    /// Closes the data streams from the Kinects and stops the application accessing the sensor.
    /// </summary>
    void OnApplicationQuit()
    {
        if (multiSourceReader != null)
        {
            multiSourceReader.Dispose();
            multiSourceReader = null;
        }

        if (kinectSensor != null)
        {
            if (kinectSensor.IsOpen)
            {
                kinectSensor.Close();
            }

            kinectSensor = null;
        }
    }
Esempio n. 21
0
        /// <summary>
        /// Raises the destroy event.
        /// </summary>
        void OnDestroy()
        {
            if (reader != null)
            {
                reader.Dispose();
                reader = null;
            }

            if (sensor != null)
            {
                if (sensor.IsOpen)
                {
                    sensor.Close();
                }

                sensor = null;
            }

            if (texture != null)
            {
                Texture2D.Destroy(texture);
                texture = null;
            }
            if (rgbaMat != null)
            {
                rgbaMat.Dispose();
                rgbaMat = null;
            }
            if (outputMat != null)
            {
                outputMat.Dispose();
                outputMat = null;
            }
            if (maskMat != null)
            {
                maskMat.Dispose();
                maskMat = null;
            }
            if (comicFilter != null)
            {
                comicFilter.Dispose();
                comicFilter = null;
            }
        }
Esempio n. 22
0
        public void Dispose()
        {
            if (_kinect != null)
            {
                if (_kinect.IsOpen)
                {
                    _kinect.Close();
                }
                _kinect = null;
            }

            if (_multiSourceFrameReader != null)
            {
                _multiSourceFrameReader.Dispose();
                _multiSourceFrameReader = null;
            }

            if (_bodyFrameReader != null)
            {
                _bodyFrameReader.Dispose();
                _bodyFrameReader = null;
            }

            if (_faceFrameSources != null)
            {
                for (int i = 0; i < _faceFrameSources.Length; i++)
                {
                    if (_faceFrameSources[i] != null)
                    {
                        _faceFrameSources[i].Dispose();
                    }
                }
            }
            if (_faceFrameReaders != null)
            {
                for (int i = 0; i < _faceFrameReaders.Length; i++)
                {
                    if (_faceFrameReaders[i] != null)
                    {
                        _faceFrameReaders[i].Dispose();
                    }
                }
            }
        }
        void OnApplicationQuit()
        {
            if (_reader != null)
            {
                _reader.Dispose();
                _reader = null;
            }

            if (_sensor == null)
            {
                return;
            }
            if (_sensor.IsOpen)
            {
                _sensor.Close();
            }

            _sensor = null;
        }
Esempio n. 24
0
    void OnApplicationQuit()
    {
        //If the reader is initialized then dump it on exit
        if (reader != null)
        {
            reader.Dispose();
            reader = null;
        }

        //If the sensor is initialized then dump it on exit
        if (sensor != null)
        {
            if (sensor.IsOpen)
            {
                sensor.Close();
            }
            sensor = null;
        }
    }
Esempio n. 25
0
        static void Main()
        {
            // Start Kinect Pipe Server
            kserver.start();

            // Start Kinect Read Event
            startRead();

            // Run untill Pipe connection is broken
            while (!connectionBroken)
            {
                Thread.Sleep(5);
            }

            // Disconnect Pipe and Kinect
            Console.WriteLine("Connection Terminated");
            kinectSensor.Close();
            kserver.stop();
        }
Esempio n. 26
0
        public static bool IsKinectConnected()
        {
            bool connected = false;

            try {
                KinectSensor sensor = KinectSensor.GetDefault();
                sensor.Open();
                Thread.Sleep(500);
                connected = sensor.IsAvailable;
                sensor.Close();
            } catch (Exception e) {
                connected = false;
            }
            if (connected)
            {
                //Console.WriteLine("Kinect Connected");
            }
            return(connected);
        }
Esempio n. 27
0
    void OnApplicationQuit()
    {
        if (depthFrameReader != null)
        {
            depthFrameReader.IsPaused = true;
            depthFrameReader.Dispose();
            depthFrameReader = null;
        }

        if (_sensor != null)
        {
            if (_sensor.IsOpen)
            {
                _sensor.Close();
            }

            _sensor = null;
        }
    }
Esempio n. 28
0
    //adding code to close Kinect sensor when exiting app
    public void OnApplicationQuit()
    {
        if (bodyFrameReader != null)
        {
            bodyFrameReader.IsPaused = true;
            bodyFrameReader.Dispose();
            bodyFrameReader = null;
        }

        if (sensor != null)
        {
            if (sensor.IsOpen)
            {
                sensor.Close();
            }

            sensor = null;
        }
    }
    // 終了処理
    private void OnApplicationQuit()
    {
        // メモリ開放
        if (_Reader != null)
        {
            _Reader.Dispose();
            _Reader = null;
        }

        // kinectをクローズ
        if (_Sensor != null)
        {
            if (_Sensor.IsOpen)
            {
                _Sensor.Close();
            }
            _Sensor = null;
        }
    }
Esempio n. 30
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _colorReader.FrameArrived -= ColorReader_FrameArrived;
            _faceReader.FrameArrived  -= FaceReader_FrameArrived;

            if (_colorReader != null)
            {
                // _colorReader.Dispose();
                //_colorReader = null;
            }

            if (_bodyReader != null)
            {
                //_bodyReader.Dispose();
                // _bodyReader = null;
            }

            if (_faceReader != null)
            {
                // _faceReader.Dispose();
                // _faceReader = null;
            }

            if (_faceSource != null)
            {
                //_faceSource.Dispose();
                //_faceSource = null;
            }

            if (_sensor != null)
            {
                _sensor.Close();
            }

            //Close show_face_features 頁面
            show_face_features.Close();

            //Open main window
            MainWindow mainWindow = new MainWindow();

            mainWindow.Show();
        }