/// <summary> /// Constructor /// </summary> /// <param name="sensor">Kinect sensor</param> public KinectSensorLongExposureInfraredFrameProvider(KinectSensor sensor) { if (sensor == null) throw new ArgumentNullException("sensor"); this.sensor = sensor; this.reader = this.sensor.LongExposureInfraredFrameSource.OpenReader(); this.reader.FrameArrived += FrameArrived; this.frameData = new LongExposureInfraredFrameData(); }
/// <summary> /// Constructor /// </summary> /// <param name="sensor">Kinect sensor</param> public KinectSensorLongExposureInfraredFrameProvider(KinectSensor sensor) { if (sensor == null) { throw new ArgumentNullException("sensor"); } this.sensor = sensor; this.reader = this.sensor.LongExposureInfraredFrameSource.OpenReader(); this.reader.FrameArrived += FrameArrived; this.frameData = new LongExposureInfraredFrameData(); }
public async Task <object> OpenLongExposureInfraredReader(dynamic input) { this.logCallback("OpenLongExposureInfraredReader"); if (this.longExposureInfraredFrameReader != null) { return(false); } this.longExposureInfraredFrameCallback = (Func <object, Task <object> >)input.longExposureInfraredFrameCallback; this.longExposureInfraredFrameDescription = this.kinectSensor.LongExposureInfraredFrameSource.FrameDescription; this.logCallback("longExposureInfrared: " + this.longExposureInfraredFrameDescription.Width + "x" + this.longExposureInfraredFrameDescription.Height); //depth data this.longExposureInfraredFrameReader = this.kinectSensor.LongExposureInfraredFrameSource.OpenReader(); this.longExposureInfraredFrameReader.FrameArrived += this.LongExposureInfraredReader_FrameArrived; this.longExposureInfraredPixels = new byte[this.longExposureInfraredFrameDescription.Width * this.longExposureInfraredFrameDescription.Height]; return(true); }
public async Task <object> Close(object input) { if (this.depthFrameReader != null) { this.depthFrameReader.Dispose(); this.depthFrameReader = null; } if (this.colorFrameReader != null) { this.colorFrameReader.Dispose(); this.colorFrameReader = null; } if (this.infraredFrameReader != null) { this.infraredFrameReader.Dispose(); this.infraredFrameReader = null; } if (this.longExposureInfraredFrameReader != null) { this.longExposureInfraredFrameReader.Dispose(); this.longExposureInfraredFrameReader = null; } if (this.bodyFrameReader != null) { this.bodyFrameReader.Dispose(); this.bodyFrameReader = null; } if (this.kinectSensor != null) { this.kinectSensor.Close(); this.kinectSensor = null; } return(true); }
public async Task<object> Close(object input) { if (this.depthFrameReader != null) { this.depthFrameReader.Dispose(); this.depthFrameReader = null; } if (this.bodyIndexFrameReader != null) { this.bodyIndexFrameReader.Dispose(); this.bodyIndexFrameReader = null; } if (this.colorFrameReader != null) { this.colorFrameReader.Dispose(); this.colorFrameReader = null; } if (this.infraredFrameReader != null) { this.infraredFrameReader.Dispose(); this.infraredFrameReader = null; } if (this.longExposureInfraredFrameReader != null) { this.longExposureInfraredFrameReader.Dispose(); this.longExposureInfraredFrameReader = null; } if (this.bodyFrameReader != null) { this.bodyFrameReader.Dispose(); this.bodyFrameReader = null; } if (this.kinectSensor != null) { this.kinectSensor.Close(); this.kinectSensor = null; } return true; }
public async Task<object> OpenLongExposureInfraredReader(dynamic input) { this.logCallback("OpenLongExposureInfraredReader"); if (this.longExposureInfraredFrameReader != null) { return false; } this.longExposureInfraredFrameCallback = (Func<object, Task<object>>)input.longExposureInfraredFrameCallback; this.longExposureInfraredFrameDescription = this.kinectSensor.LongExposureInfraredFrameSource.FrameDescription; this.logCallback("longExposureInfrared: " + this.longExposureInfraredFrameDescription.Width + "x" + this.longExposureInfraredFrameDescription.Height); //depth data this.longExposureInfraredFrameReader = this.kinectSensor.LongExposureInfraredFrameSource.OpenReader(); this.longExposureInfraredFrameReader.FrameArrived += this.LongExposureInfraredReader_FrameArrived; this.longExposureInfraredPixels = new byte[this.longExposureInfraredFrameDescription.Width * this.longExposureInfraredFrameDescription.Height]; return true; }
/// <summary> /// Converts the LongExposureInfraredFrameArrived event to an observable sequence and uses the specified reader. /// </summary> /// <param name="kinectSensor">The kinect sensor.</param> /// <param name="kinectSensor">The reader to be used to subscribe to the FrameArrived event.</param> /// <returns>The observable sequence.</returns> public static IObservable <LongExposureInfraredFrameArrivedEventArgs> LongExposureInfraredFrameArrivedObservable(this KinectSensor kinectSensor, LongExposureInfraredFrameReader reader) { if (kinectSensor == null) { throw new ArgumentNullException("kinectSensor"); } return(Observable.FromEventPattern <EventHandler <LongExposureInfraredFrameArrivedEventArgs>, LongExposureInfraredFrameArrivedEventArgs>( h => h.Invoke, h => reader.FrameArrived += h, h => reader.FrameArrived -= h) .Select(e => e.EventArgs)); }
/// <summary> /// Called when the kinect sensor is available. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="IsAvailableChangedEventArgs"/> instance containing the event data.</param> private void OnSensor_IsAvailableChanged(object sender, IsAvailableChangedEventArgs e) { // This call is automatically dispatched to the main thread, so no // synchronization is needed base.RaisePropertyChanged(() => UniqueKinectId); base.RaisePropertyChanged(() => IsSensorOpen); base.RaisePropertyChanged(() => IsSensorAvailable); if(e.IsAvailable) { m_readerInfraredFrame = m_sensor.InfraredFrameSource.OpenReader(); m_readerInfraredFrame.FrameArrived += OnReaderInfraredFrame_FrameArrived; m_readerLongExposureInfraredFrame = m_sensor.LongExposureInfraredFrameSource.OpenReader(); m_readerLongExposureInfraredFrame.FrameArrived += OnReaderLongExposureInfrared_FrameArrived; m_readerColorFrame = m_sensor.ColorFrameSource.OpenReader(); m_readerColorFrame.FrameArrived += OnReaderColorFrame_FrameArrived; m_readerDepthFrame = m_sensor.DepthFrameSource.OpenReader(); m_readerDepthFrame.FrameArrived += OnReaderDepthFrame_FrameArrived; m_readerBodyFrame = m_sensor.BodyFrameSource.OpenReader(); m_readerBodyFrame.FrameArrived += OnReaderBodyFrame_FrameArrived; m_readerBodyIndexFrame = m_sensor.BodyIndexFrameSource.OpenReader(); m_readerBodyIndexFrame.FrameArrived += OnReaderBodyIndexFrame_FrameArrived; } else { CommonTools.SafeDispose(ref m_readerInfraredFrame); CommonTools.SafeDispose(ref m_readerColorFrame); CommonTools.SafeDispose(ref m_readerDepthFrame); CommonTools.SafeDispose(ref m_readerBodyFrame); CommonTools.SafeDispose(ref m_readerBodyIndexFrame); } }
/// <summary> /// Converts the LongExposureInfraredFrameArrived event to an observable sequence and uses the specified reader. /// </summary> /// <param name="kinectSensor">The kinect sensor.</param> /// <param name="kinectSensor">The reader to be used to subscribe to the FrameArrived event.</param> /// <returns>The observable sequence.</returns> public static IObservable <LongExposureInfraredFrameArrivedEventArgs> LongExposureInfraredFrameArrivedObservable(this KinectSensor kinectSensor, LongExposureInfraredFrameReader reader) { if (kinectSensor == null) { throw new ArgumentNullException("kinectSensor"); } return(FrameArrivedEventArgsFromEventPattern <LongExposureInfraredFrameArrivedEventArgs>(reader)); }