Пример #1
0
        /// <summary>
        /// Decodes the depth image using a specified decoder.
        /// </summary>
        /// <param name="depthImageDecoder">The depth image decoder to use.</param>
        /// <returns>A new, corresponding decoded depth image.</returns>
        public DepthImage Decode(IDepthImageFromStreamDecoder depthImageDecoder)
        {
            var depthImage = new DepthImage(this.Width, this.Height);

            depthImage.DecodeFrom(this, depthImageDecoder);
            return(depthImage);
        }
Пример #2
0
        /// <summary>
        /// Decodes the depth image using a specified decoder.
        /// </summary>
        /// <param name="depthImageDecoder">The depth image decoder to use.</param>
        /// <returns>A new, corresponding decoded depth image.</returns>
        public DepthImage Decode(IDepthImageFromStreamDecoder depthImageDecoder)
        {
            var depthImage = new DepthImage(this.Width, this.Height, this.DepthValueSemantics, this.DepthValueToMetersScaleFactor);

            depthImage.DecodeFrom(this, depthImageDecoder);
            return(depthImage);
        }
Пример #3
0
        /// <summary>
        /// Decodes a specified encoded depth image with a specified decoder into the current depth image.
        /// </summary>
        /// <param name="encodedDepthImage">The encoded depth image to decode.</param>
        /// <param name="depthImageDecoder">The depth image decoder to use.</param>
        /// <remarks>The depth image width, height and pixel format must match. The method should not be called concurrently.</remarks>
        public void DecodeFrom(EncodedDepthImage encodedDepthImage, IDepthImageFromStreamDecoder depthImageDecoder)
        {
            if (encodedDepthImage.Width != this.Width || encodedDepthImage.Height != this.Height || encodedDepthImage.PixelFormat != this.PixelFormat)
            {
                throw new InvalidOperationException("Cannot decode from an encoded depth image that has a different width, height, or pixel format.");
            }

            depthImageDecoder.DecodeFromStream(encodedDepthImage.ToStream(), this);
        }
Пример #4
0
        /// <summary>
        /// Decodes a specified encoded depth image with a specified decoder into the current depth image.
        /// </summary>
        /// <param name="encodedDepthImage">The encoded depth image to decode.</param>
        /// <param name="depthImageDecoder">The depth image decoder to use.</param>
        /// <remarks>The depth image width, height and pixel format must match. The method should not be called concurrently.</remarks>
        public void DecodeFrom(EncodedDepthImage encodedDepthImage, IDepthImageFromStreamDecoder depthImageDecoder)
        {
            if (encodedDepthImage.Width != this.Width ||
                encodedDepthImage.Height != this.Height ||
                encodedDepthImage.PixelFormat != this.PixelFormat ||
                encodedDepthImage.DepthValueSemantics != this.DepthValueSemantics ||
                encodedDepthImage.DepthValueToMetersScaleFactor != this.DepthValueToMetersScaleFactor)
            {
                throw new InvalidOperationException("Cannot decode from an encoded depth image that has a different width, height, pixel format, depth value semantics or depth value scale factor.");
            }

            depthImageDecoder.DecodeFromStream(encodedDepthImage.ToStream(), this);
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DepthImageCompressor"/> class.
        /// </summary>
        /// <param name="depthCompressionMethod">The depth compression method to be used.</param>
        public DepthImageCompressor(DepthCompressionMethod depthCompressionMethod)
        {
            this.DepthCompressionMethod = depthCompressionMethod;
            switch (this.DepthCompressionMethod)
            {
            case DepthCompressionMethod.Png:
                this.encoder = new DepthImageToPngStreamEncoder();
                break;

            case DepthCompressionMethod.None:
                break;
            }

            this.decoder = new DepthImageFromStreamDecoder();
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DepthImageCompressor"/> class.
        /// </summary>
        /// <param name="depthCompressionMethod">The depth compression method to be used.</param>
        public DepthImageCompressor(DepthCompressionMethod depthCompressionMethod)
        {
            this.DepthCompressionMethod = depthCompressionMethod;
            switch (this.DepthCompressionMethod)
            {
            case DepthCompressionMethod.Png:
                this.encoder = new DepthImageToPngStreamEncoder();
                break;

            case DepthCompressionMethod.Tiff:
                throw new NotImplementedException();

            case DepthCompressionMethod.None:
                break;
            }

            this.decoder = new DepthImageFromStreamDecoder();
        }
Пример #7
0
 /// <summary>
 /// Decodes an encoded depth image image rectangle using a specified depth image decoder.
 /// </summary>
 /// <param name="source">The source stream of encoded depth image rectangles.</param>
 /// <param name="decoder">The depth image decoder to use.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <param name="name">An optional name for the stream operator.</param>
 /// <returns>A stream of decoded depth image rectangles.</returns>
 public static IProducer <DepthImageRectangle3D> Decode(
     this IProducer <EncodedDepthImageRectangle3D> source,
     IDepthImageFromStreamDecoder decoder,
     DeliveryPolicy <EncodedDepthImageRectangle3D> deliveryPolicy = null,
     string name = nameof(Decode))
 {
     return(source.Process <EncodedDepthImageRectangle3D, DepthImageRectangle3D>(
                (encodedDepthImageRectangle3D, envelope, emitter) =>
     {
         var encodedDepthImage = encodedDepthImageRectangle3D.Image.Resource;
         using var depthImage = DepthImagePool.GetOrCreate(
                   encodedDepthImage.Width,
                   encodedDepthImage.Height,
                   encodedDepthImage.DepthValueSemantics,
                   encodedDepthImage.DepthValueToMetersScaleFactor);
         depthImage.Resource.DecodeFrom(encodedDepthImage, decoder);
         emitter.Post(new DepthImageRectangle3D(encodedDepthImageRectangle3D.Rectangle3D, depthImage), envelope.OriginatingTime);
     },
                deliveryPolicy,
                name));
 }
Пример #8
0
 /// <summary>
 /// Decodes an encoded depth image camera view using a specified image decoder.
 /// </summary>
 /// <param name="source">The source stream of encoded depth image camera views.</param>
 /// <param name="decoder">The depth image decoder to use.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <param name="name">An optional name for the stream operator.</param>
 /// <returns>A stream of decoded depth image camera views.</returns>
 public static IProducer <DepthImageCameraView> Decode(
     this IProducer <EncodedDepthImageCameraView> source,
     IDepthImageFromStreamDecoder decoder,
     DeliveryPolicy <EncodedDepthImageCameraView> deliveryPolicy = null,
     string name = nameof(Decode))
 {
     return(source.Process <EncodedDepthImageCameraView, DepthImageCameraView>(
                (encodedDepthImageCameraView, envelope, emitter) =>
     {
         var encodedDepthImage = encodedDepthImageCameraView.ViewedObject.Resource;
         using var depthImage = DepthImagePool.GetOrCreate(
                   encodedDepthImage.Width,
                   encodedDepthImage.Height,
                   encodedDepthImage.DepthValueSemantics,
                   encodedDepthImage.DepthValueToMetersScaleFactor);
         depthImage.Resource.DecodeFrom(encodedDepthImage, decoder);
         using var depthImageCameraView = new DepthImageCameraView(depthImage, encodedDepthImageCameraView.CameraIntrinsics, encodedDepthImageCameraView.CameraPose);
         emitter.Post(depthImageCameraView, envelope.OriginatingTime);
     },
                deliveryPolicy,
                name));
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DepthImageDecoder"/> class.
 /// </summary>
 /// <param name="pipeline">Pipeline to add this component to.</param>
 /// <param name="decoder">The depth image decoder to use.</param>
 public DepthImageDecoder(Pipeline pipeline, IDepthImageFromStreamDecoder decoder)
     : base(pipeline)
 {
     this.decoder = decoder;
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DepthImageDecoder"/> class.
 /// </summary>
 /// <param name="pipeline">The pipeline to add the component to.</param>
 /// <param name="decoder">The depth image decoder to use.</param>
 /// <param name="name">An optional name for the component.</param>
 public DepthImageDecoder(Pipeline pipeline, IDepthImageFromStreamDecoder decoder, string name = nameof(DepthImageDecoder))
     : base(pipeline, name)
 {
     this.decoder = decoder;
 }