Ejemplo n.º 1
0
        /// <summary>
        /// Start depth stream at specific resolution
        /// </summary>
        /// <param name="sensor">The reconstruction sensor instance.</param>
        /// <param name="format">The resolution of image in depth stream.</param>
        /// <returns>Returns true if the sensor supports near mode.</returns>
        private bool StartDepthStream(ReconstructionSensor sensor, DepthImageFormat format)
        {
            if (sensor == null)
            {
                return true;
            }

            bool isSupportNearMode = true;
            try
            {
                // Enable depth stream, register event handler and start
                sensor.DepthFrameReady += this.OnDepthFrameReady;
                isSupportNearMode = sensor.StartDepthStream(format);
            }
            catch (IOException ex)
            {
                // Device is in use
                this.ShowStatusMessage(ex.Message);

                return isSupportNearMode;
            }
            catch (InvalidOperationException ex)
            {
                // Device is not valid, not supported or hardware feature unavailable
                this.ShowStatusMessage(ex.Message);

                return isSupportNearMode;
            }

            try
            {
                // Make sure Lasers are turned on
                sensor.Sensor.ForceInfraredEmitterOff = false;
            }
            catch (InvalidOperationException ex)
            {
                // Device is not valid, not supported or hardware feature unavailable
                // show an error message just this once
                this.ShowStatusMessage(ex.Message);
            }

            return isSupportNearMode;
        }