Beispiel #1
0
 /// <summary>
 /// Encodes a depth image rectangle using a specified depth image encoder.
 /// </summary>
 /// <param name="source">The source stream of depth image rectangles.</param>
 /// <param name="encoder">The depth image encoder 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 encoded depth image rectangles.</returns>
 public static IProducer <EncodedDepthImageRectangle3D> Encode(
     this IProducer <DepthImageRectangle3D> source,
     IDepthImageToStreamEncoder encoder,
     DeliveryPolicy <DepthImageRectangle3D> deliveryPolicy = null,
     string name = null)
 {
     return(source.Process <DepthImageRectangle3D, EncodedDepthImageRectangle3D>(
                (depthImageRectangle3D, envelope, emitter) =>
     {
         var depthImage = depthImageRectangle3D.Image.Resource;
         using var encodedDepthImage = EncodedDepthImagePool.GetOrCreate(
                   depthImage.Width,
                   depthImage.Height,
                   depthImage.DepthValueSemantics,
                   depthImage.DepthValueToMetersScaleFactor);
         encodedDepthImage.Resource.EncodeFrom(depthImage, encoder);
         emitter.Post(new EncodedDepthImageRectangle3D(depthImageRectangle3D.Rectangle3D, encodedDepthImage), envelope.OriginatingTime);
     },
                deliveryPolicy,
                name ?? $"{nameof(Encode)}({encoder.Description})"));
 }
Beispiel #2
0
 /// <summary>
 /// Encodes a depth image camera view using a specified image encoder.
 /// </summary>
 /// <param name="source">The source stream of depth image camera views.</param>
 /// <param name="encoder">The image encoder 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 encoded depth image camera views.</returns>
 public static IProducer <EncodedDepthImageCameraView> Encode(
     this IProducer <DepthImageCameraView> source,
     IDepthImageToStreamEncoder encoder,
     DeliveryPolicy <DepthImageCameraView> deliveryPolicy = null,
     string name = null)
 {
     return(source.Process <DepthImageCameraView, EncodedDepthImageCameraView>(
                (depthImageCameraView, envelope, emitter) =>
     {
         var depthImage = depthImageCameraView.ViewedObject.Resource;
         using var encodedDepthImage = EncodedDepthImagePool.GetOrCreate(
                   depthImage.Width,
                   depthImage.Height,
                   depthImage.DepthValueSemantics,
                   depthImage.DepthValueToMetersScaleFactor);
         encodedDepthImage.Resource.EncodeFrom(depthImage, encoder);
         using var encodedDepthImageCameraView = new EncodedDepthImageCameraView(encodedDepthImage, depthImageCameraView.CameraIntrinsics, depthImageCameraView.CameraPose);
         emitter.Post(encodedDepthImageCameraView, envelope.OriginatingTime);
     },
                deliveryPolicy,
                name ?? $"{nameof(Encode)}({encoder.Description})"));
 }