Exemple #1
0
        public async Task JpegThumbnail()
        {
            TestHelper.BeginTest("Image - JpegThumbnail");
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/images/tests");

            JpegThumbnail tm = new JpegThumbnail(true, 200, 200, 90);

            using (var imgCaptureHandler = new ImageStreamCaptureHandler("/home/pi/images/tests", "jpg"))
                using (var preview = new MMALNullSinkComponent())
                    using (var imgEncoder = new MMALImageEncoder(thumbnailConfig: tm))
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        var portConfig = new MMALPortConfig(MMALEncoding.JPEG, MMALEncoding.I420, 90);

                        imgEncoder.ConfigureOutputPort(portConfig, imgCaptureHandler);

                        // Create our component pipeline.
                        Fixture.MMALCamera.Camera.StillPort
                        .ConnectTo(imgEncoder);
                        Fixture.MMALCamera.Camera.PreviewPort
                        .ConnectTo(preview);

                        imgCaptureHandler.Manipulate(context =>
                        {
                            context.StripBayerMetadata(CameraVersion.OV5647);
                        }, ImageFormat.Jpeg);

                        // Camera warm up time
                        await Task.Delay(2000);

                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.StillPort);
                    }
        }
Exemple #2
0
        /// <summary>
        /// Creates a new instance of the <see cref="MMALImageEncoder"/> class with the specified handler.
        /// </summary>
        /// <param name="rawBayer">Specifies whether to include raw bayer image data.</param>
        /// <param name="useExif">Specifies whether any EXIF tags should be used.</param>
        /// <param name="continuousCapture">Configure component for rapid capture mode.</param>
        /// <param name="thumbnailConfig">Configures the embedded JPEG thumbnail.</param>
        /// <param name="exifTags">A collection of custom EXIF tags.</param>
        public MMALImageEncoder(bool rawBayer = false, bool useExif = true, bool continuousCapture = false, JpegThumbnail thumbnailConfig = null, params ExifTag[] exifTags)
            : base(MMALParameters.MMAL_COMPONENT_DEFAULT_IMAGE_ENCODER)
        {
            this.RawBayer            = rawBayer;
            this.UseExif             = useExif;
            this.ExifTags            = exifTags;
            this.ContinuousCapture   = continuousCapture;
            this.JpegThumbnailConfig = thumbnailConfig;

            this.Inputs.Add(new InputPort((IntPtr)(&(*this.Ptr->Input[0])), this, Guid.NewGuid()));

            if (this.ContinuousCapture)
            {
                this.Outputs.Add(new FastStillPort((IntPtr)(&(*this.Ptr->Output[0])), this, Guid.NewGuid()));
            }
            else
            {
                this.Outputs.Add(new StillPort((IntPtr)(&(*this.Ptr->Output[0])), this, Guid.NewGuid()));
            }
        }