コード例 #1
0
ファイル: ImagingOperators.cs プロジェクト: sandrist/psi
 /// <summary>
 /// Encodes an image to a JPEG format.
 /// </summary>
 /// <param name="source">A producer of images to encode.</param>
 /// <param name="quality">JPEG quality to use.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <param name="name">An optional name for the stream operator.</param>
 /// <returns>A producer that generates the JPEG images.</returns>
 public static IProducer <Shared <EncodedImage> > EncodeJpeg(
     this IProducer <Shared <Image> > source,
     int quality = 90,
     DeliveryPolicy <Shared <Image> > deliveryPolicy = null,
     string name = null)
 => source.Encode(new ImageToJpegStreamEncoder {
     QualityLevel = quality
 }, deliveryPolicy, name ?? $"{nameof(EncodeJpeg)}({quality})");
コード例 #2
0
ファイル: Operators.cs プロジェクト: sandrist/psi
        /// <summary>
        /// Exports a stream of depth image camera views.
        /// </summary>
        /// <param name="source">The source stream of depth image camera views.</param>
        /// <param name="name">The name for the source stream.</param>
        /// <param name="outputPath">The output path.</param>
        /// <param name="streamWritersToClose">The collection of stream writers to be closed.</param>
        internal static void Export(this IProducer <DepthImageCameraView> source, string name, string outputPath, List <StreamWriter> streamWritersToClose)
        {
            var timingFilePath = DataExporter.EnsurePathExists(Path.Combine(outputPath, name, $"Timing.txt"));
            var timingFile     = File.CreateText(timingFilePath);

            streamWritersToClose.Add(timingFile);

            var poseFilePath = DataExporter.EnsurePathExists(Path.Combine(outputPath, name, $"Pose.txt"));
            var poseFile     = File.CreateText(poseFilePath);

            streamWritersToClose.Add(poseFile);

            var intrinsicsFilePath = DataExporter.EnsurePathExists(Path.Combine(outputPath, name, $"Intrinsics.txt"));
            var intrinsicsFile     = File.CreateText(intrinsicsFilePath);

            streamWritersToClose.Add(intrinsicsFile);

            var depthImageCounter = 0;

            source
            .Encode(new DepthImageToPngStreamEncoder(), DeliveryPolicy.SynchronousOrThrottle)
            .Do(
                (edicv, envelope) =>
            {
                var buffer               = edicv.ViewedObject.Resource.GetBuffer();
                var depthImagesPath      = DataExporter.EnsurePathExists(Path.Combine(outputPath, name, $"{depthImageCounter:000000}.png"));
                using var depthImageFile = File.Create(depthImagesPath);
                depthImageFile.Write(buffer, 0, buffer.Length);
                timingFile.WriteLine($"{depthImageCounter}\t{envelope.OriginatingTime.ToText()}");
                poseFile.WriteLine($"{envelope.OriginatingTime.ToText()}\t{edicv.CameraPose.ToText()}");

                if (depthImageCounter == 0)
                {
                    intrinsicsFile.WriteLine(edicv.CameraIntrinsics.ToText());
                }

                depthImageCounter++;
            },
                DeliveryPolicy.SynchronousOrThrottle);
        }
コード例 #3
0
 /// <summary>
 /// Encodes a depth image to a TIFF format.
 /// </summary>
 /// <param name="source">A producer of depth images to encode.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <returns>A producer that generates the TIFF-encoded depth images.</returns>
 public static IProducer <Shared <EncodedDepthImage> > EncodeTiff(this IProducer <Shared <DepthImage> > source, DeliveryPolicy <Shared <DepthImage> > deliveryPolicy = null)
 {
     return(source.Encode(new DepthImageToTiffStreamEncoder(), deliveryPolicy));
 }
コード例 #4
0
 /// <summary>
 /// Encodes an image to a PNG format.
 /// </summary>
 /// <param name="source">A producer of images to encoder.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <returns>A producer that generates the PNG images.</returns>
 public static IProducer <Shared <EncodedImage> > EncodePng(this IProducer <Shared <Image> > source, DeliveryPolicy <Shared <Image> > deliveryPolicy = null)
 {
     return(source.Encode(new ImageToPngStreamEncoder(), deliveryPolicy));
 }
コード例 #5
0
 /// <summary>
 /// Encodes an image to a JPEG format.
 /// </summary>
 /// <param name="source">A producer of images to encode.</param>
 /// <param name="quality">JPEG quality to use.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <returns>A producer that generates the JPEG images.</returns>
 public static IProducer <Shared <EncodedImage> > EncodeJpeg(this IProducer <Shared <Image> > source, int quality = 90, DeliveryPolicy <Shared <Image> > deliveryPolicy = null)
 {
     return(source.Encode(new ImageToJpegStreamEncoder {
         QualityLevel = quality
     }, deliveryPolicy));
 }
コード例 #6
0
ファイル: ImagingOperators.cs プロジェクト: sandrist/psi
 /// <summary>
 /// Encodes a depth image to a TIFF format.
 /// </summary>
 /// <param name="source">A producer of depth images to encode.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <param name="name">An optional name for the stream operator.</param>
 /// <returns>A producer that generates the TIFF-encoded depth images.</returns>
 public static IProducer <Shared <EncodedDepthImage> > EncodeTiff(
     this IProducer <Shared <DepthImage> > source,
     DeliveryPolicy <Shared <DepthImage> > deliveryPolicy = null,
     string name = nameof(EncodeTiff))
 => source.Encode(new DepthImageToTiffStreamEncoder(), deliveryPolicy, name);
コード例 #7
0
ファイル: ImagingOperators.cs プロジェクト: sandrist/psi
 /// <summary>
 /// Encodes an image to a GZIP format.
 /// </summary>
 /// <param name="source">A producer of images to encode.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <param name="name">An optional name for the stream operator.</param>
 /// <returns>A producer that generates the GZipped images.</returns>
 public static IProducer <Shared <EncodedImage> > EncodeGZip(
     this IProducer <Shared <Image> > source,
     DeliveryPolicy <Shared <Image> > deliveryPolicy = null,
     string name = nameof(EncodeGZip))
 => source.Encode(new ImageToGZipStreamEncoder(), deliveryPolicy, name);