AForge.Video.Kinect.KinectNative.freenect_stop_video C# (CSharp) Method

freenect_stop_video() public static method

public static freenect_stop_video ( IntPtr device ) : int
device IntPtr
return int
        public static int freenect_stop_video( IntPtr device )
        {
            lock ( sync )
            {
                return native_freenect_stop_video( device );
            }
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Stop video source.
        /// </summary>
        ///
        /// <remarks><para>The method stops the video source, so it no longer provides new video frames
        /// and does not consume any resources.</para>
        /// </remarks>
        ///
        public void Stop()
        {
            lock (sync)
            {
                lock (runningCameras)
                {
                    if (device != null)
                    {
                        var deviceFailed = Kinect.IsDeviceFailed(deviceID);

                        if (!deviceFailed)
                        {
                            KinectNative.freenect_stop_video(device.RawDevice);
                        }

                        device.Dispose();
                        device = null;
                        runningCameras.Remove(deviceID);

                        if (PlayingFinished != null)
                        {
                            PlayingFinished(this, (!deviceFailed) ?
                                            ReasonToFinishPlaying.StoppedByUser : ReasonToFinishPlaying.DeviceLost);
                        }
                    }

                    if (imageBuffer != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(imageBuffer);
                        imageBuffer = IntPtr.Zero;
                    }

                    videoCallback = null;
                }
            }
        }