Exemple #1
0
        public async Task TakeVideo(string extension, MMALEncoding encodingType, MMALEncoding pixelFormat)
        {
            TestHelper.BeginTest("TakeVideo", encodingType.EncodingName, pixelFormat.EncodingName);
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/videos/tests");

            using (var vidCaptureHandler = new VideoStreamCaptureHandler("/home/pi/videos/tests", extension))
                using (var preview = new MMALVideoRenderer())
                    using (var vidEncoder = new MMALVideoEncoder(vidCaptureHandler))
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        var portConfig = new MMALPortConfig(encodingType, pixelFormat, 25, 10, 25000000, null);

                        vidEncoder.ConfigureOutputPort(portConfig);

                        // Create our component pipeline.
                        Fixture.MMALCamera.Camera.VideoPort
                        .ConnectTo(vidEncoder);
                        Fixture.MMALCamera.Camera.PreviewPort
                        .ConnectTo(preview);

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

                        CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));

                        // Record video for 20 seconds
                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                        Fixture.CheckAndAssertFilepath(vidCaptureHandler.GetFilepath());
                    }
        }
        public async Task EdgeDetectionKernelProcessor(string extension, MMALEncoding encodingType, MMALEncoding pixelFormat)
        {
            TestHelper.BeginTest("EdgeDetectionKernelProcessor", encodingType.EncodingName, pixelFormat.EncodingName);
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/images/tests");

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

                        var portConfig = new MMALPortConfig(encodingType, pixelFormat, 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.Apply(new EdgeDetection(EDStrength.High));
                        }, ImageFormat.Jpeg);

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

                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.StillPort);

                        Fixture.CheckAndAssertFilepath(imgCaptureHandler.GetFilepath());
                    }
        }
Exemple #3
0
        public async Task TakePicturesFromVideoPortWithCustomFilename(string extension, MMALEncoding encodingType, MMALEncoding pixelFormat)
        {
            TestHelper.BeginTest("TakePicturesFromVideoPortWithCustomFilename", encodingType.EncodingName, pixelFormat.EncodingName);
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/images/tests");

            using (var imgCaptureHandler = new ImageStreamCaptureHandler($"/home/pi/images/tests/fromVideoPort.{extension}"))
                using (var splitter = new MMALSplitterComponent())
                    using (var preview = new MMALNullSinkComponent())
                        using (var imgEncoder = new MMALImageEncoder(continuousCapture: true))
                        {
                            Fixture.MMALCamera.ConfigureCameraSettings();

                            var portConfig = new MMALPortConfig(encodingType, pixelFormat, 90);

                            imgEncoder.ConfigureOutputPort(portConfig, imgCaptureHandler);

                            // Create our component pipeline.
                            Fixture.MMALCamera.Camera.VideoPort
                            .ConnectTo(splitter);
                            splitter.Outputs[0].ConnectTo(imgEncoder);
                            Fixture.MMALCamera.Camera.PreviewPort
                            .ConnectTo(preview);

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

                            var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));

                            await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                            Fixture.CheckAndAssertDirectory(imgCaptureHandler.Directory);
                        }
        }
Exemple #4
0
        public async Task TakePictureWithInMemoryHandler()
        {
            TestHelper.BeginTest("TakePictureWithInMemoryHandler");
            TestHelper.SetConfigurationDefaults();

            var imgCaptureHandler = new InMemoryCaptureHandler();

            using (var preview = new MMALNullSinkComponent())
                using (var imgEncoder = new MMALImageEncoder(true))
                {
                    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);

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

                    await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.StillPort);

                    Assert.True(imgCaptureHandler.WorkingData.Count > 0);
                }
        }
        public async Task UserProvidedBufferNumAndSize()
        {
            TestHelper.BeginTest("UserProvidedBufferNumAndSize");
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/images/tests");

            MMALCameraConfig.UserBufferNum  = 10;
            MMALCameraConfig.UserBufferSize = 20000;

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

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

                        imgEncoder.ConfigureOutputPort(portConfig, imgCaptureHandler);

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

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

                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.StillPort);

                        Fixture.CheckAndAssertFilepath(imgCaptureHandler.GetFilepath());
                    }
        }
Exemple #6
0
        public async Task RecordVideoDirectlyFromResizer()
        {
            TestHelper.BeginTest("RecordVideoDirectlyFromResizer");
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/videos/tests");

            using (var vidCaptureHandler = new VideoStreamCaptureHandler("/home/pi/videos/tests", "raw"))
                using (var preview = new MMALVideoRenderer())
                    using (var resizer = new MMALResizerComponent())
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        // Use the resizer to resize 1080p to 640x480.
                        var portConfig = new MMALPortConfig(MMALEncoding.I420, MMALEncoding.I420, 640, 480, 0, 0, 0, false, null);

                        resizer.ConfigureOutputPort <VideoPort>(0, portConfig, vidCaptureHandler);

                        // Create our component pipeline.
                        Fixture.MMALCamera.Camera.VideoPort
                        .ConnectTo(resizer);
                        Fixture.MMALCamera.Camera.PreviewPort
                        .ConnectTo(preview);

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

                        CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));

                        // Record video for 20 seconds
                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                        Fixture.CheckAndAssertFilepath(vidCaptureHandler.GetFilepath());
                    }
        }
        public async Task TakePictureWithCustomConnectionCallbackHandler()
        {
            TestHelper.BeginTest("TakePictureWithCustomConnectionCallbackHandler");
            TestHelper.SetConfigurationDefaults();

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

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

                        imgEncoder.ConfigureOutputPort(portConfig, imgCaptureHandler);

                        // Create our component pipeline.
                        var connection = Fixture.MMALCamera.Camera.StillPort
                                         .ConnectTo(imgEncoder, 0, true);

                        Fixture.MMALCamera.Camera.PreviewPort
                        .ConnectTo(preview);

                        // Register our custom connection callback handler.
                        connection.RegisterCallbackHandler(new CustomConnectionCallbackHandler(connection));

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

                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.StillPort);

                        Fixture.CheckAndAssertFilepath(imgCaptureHandler.GetFilepath());
                    }
        }
        public async Task TakePictureRawBayer(string extension, MMALEncoding encodingType, MMALEncoding pixelFormat)
        {
            TestHelper.BeginTest("TakePictureRawBayer", encodingType.EncodingName, pixelFormat.EncodingName);
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/images/tests");

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

                        var portConfig = new MMALPortConfig(encodingType, pixelFormat, quality: 90);

                        imgEncoder.ConfigureOutputPort(portConfig, imgCaptureHandler);

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

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

                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.StillPort);

                        Fixture.CheckAndAssertFilepath(imgCaptureHandler.GetFilepath());
                    }
        }
        public async Task TakePictureTimeout()
        {
            TestHelper.BeginTest("TakePictureTimeout");
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/images/tests/split_tests");

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

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

                        imgEncoder.ConfigureOutputPort(portConfig, imgCaptureHandler);

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

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

                        var timeout = DateTime.Now.AddSeconds(10);
                        while (DateTime.Now.CompareTo(timeout) < 0)
                        {
                            await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.StillPort);
                        }

                        Fixture.CheckAndAssertDirectory(imgCaptureHandler.Directory);
                    }
        }
Exemple #10
0
        public async Task TakeVideoWithCircularBuffer(string extension, MMALEncoding encodingType, MMALEncoding pixelFormat)
        {
            TestHelper.BeginTest("TakeVideoWithCircularBuffer", encodingType.EncodingName, pixelFormat.EncodingName);
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/videos/tests");

            using (var circularBufferHandler = new CircularBufferCaptureHandler(4096, "/home/pi/videos/tests", extension))
                using (var preview = new MMALVideoRenderer())
                    using (var vidEncoder = new MMALVideoEncoder())
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        var portConfig = new MMALPortConfig(encodingType, pixelFormat, 10, 25000000, null, storeMotionVectors: true);

                        vidEncoder.ConfigureOutputPort(portConfig, circularBufferHandler);

                        // Create our component pipeline.
                        Fixture.MMALCamera.Camera.VideoPort
                        .ConnectTo(vidEncoder);
                        Fixture.MMALCamera.Camera.PreviewPort
                        .ConnectTo(preview);

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

                        CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));

                        // Record video for 10 seconds
                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                        // Check that the circular buffer has stored some data during the recording operation.
                        Assert.True(circularBufferHandler.Buffer.Size > 0);
                    }
        }
Exemple #11
0
        public async Task AnnotateVideoRefreshSeconds()
        {
            TestHelper.BeginTest("Video - AnnotateVideo");
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/videos/tests");

            MMALCameraConfig.Annotate             = new AnnotateImage();
            MMALCameraConfig.Annotate.RefreshRate = DateTimeTextRefreshRate.Seconds;
            MMALCameraConfig.Annotate.TimeFormat  = "HH:mm:ss";

            using (var vidCaptureHandler = new VideoStreamCaptureHandler("/home/pi/videos/tests", "h264"))
                using (var vidEncoder = new MMALVideoEncoder())
                    using (var renderer = new MMALVideoRenderer())
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        var portConfig = new MMALPortConfig(MMALEncoding.H264, MMALEncoding.I420, quality: 10, bitrate: MMALVideoEncoder.MaxBitrateLevel4);

                        // Create our component pipeline. Here we are using the H.264 standard with a YUV420 pixel format. The video will be taken at 25Mb/s.
                        vidEncoder.ConfigureOutputPort(portConfig, vidCaptureHandler);

                        Fixture.MMALCamera.Camera.VideoPort.ConnectTo(vidEncoder);
                        Fixture.MMALCamera.Camera.PreviewPort.ConnectTo(renderer);

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

                        var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));

                        // Take video for 30 seconds.
                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                        Fixture.CheckAndAssertFilepath(vidCaptureHandler.GetFilepath());
                    }
        }
        public void ImagesToVideo()
        {
            TestHelper.BeginTest("ImagesToVideo");
            TestHelper.SetConfigurationDefaults();

            AsyncContext.Run(async() =>
            {
                TestHelper.CleanDirectory("/home/pi/videos/tests");
                TestHelper.CleanDirectory("/home/pi/images/tests");

                // This example will take an image every 5 seconds for 1 minute.
                using (var imgCaptureHandler = new ImageStreamCaptureHandler("/home/pi/images/tests", "jpg"))
                {
                    var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));

                    var tl = new Timelapse {
                        Mode = TimelapseMode.Second, CancellationToken = cts.Token, Value = 5
                    };
                    await _fixture.MMALCamera.TakePictureTimelapse(imgCaptureHandler, MMALEncoding.JPEG, MMALEncoding.I420, tl);

                    // Process all images captured into a video at 2fps.
                    imgCaptureHandler.ImagesToVideo("/home/pi/videos/tests", 2);

                    _fixture.CheckAndAssertFilepath("/home/pi/videos/tests/out.avi");
                }
            });
        }
Exemple #13
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);
                    }
        }
        public void TakePictureRawSensor(string extension, MMALEncoding encodingType, MMALEncoding pixelFormat)
        {
            TestHelper.BeginTest("TakePictureRawSensor", encodingType.EncodingName, pixelFormat.EncodingName);
            TestHelper.SetConfigurationDefaults();

            AsyncContext.Run(async() =>
            {
                using (var imgCaptureHandler = new ImageStreamCaptureHandler("/home/pi/images/tests", extension))
                {
                    TestHelper.CleanDirectory("/home/pi/images/tests");

                    await _fixture.MMALCamera.TakeRawPicture(imgCaptureHandler);

                    var encodings = _fixture.MMALCamera.Camera.StillPort.GetSupportedEncodings();

                    if (System.IO.File.Exists(imgCaptureHandler.GetFilepath()))
                    {
                        var length = new System.IO.FileInfo(imgCaptureHandler.GetFilepath()).Length;

                        if (encodings.Contains(encodingType.EncodingVal))
                        {
                            Assert.True(length > 1);
                        }
                    }
                    else
                    {
                        Assert.True(false, $"File {imgCaptureHandler.GetFilepath()} was not created");
                    }
                }
            });
        }
        public void TakePictureTimeout()
        {
            TestHelper.BeginTest("TakePictureTimeout");
            TestHelper.SetConfigurationDefaults();

            AsyncContext.Run(async() =>
            {
                TestHelper.CleanDirectory("/home/pi/images/tests/split_tests");

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

                            imgEncoder.ConfigureOutputPort(0, MMALEncoding.JPEG, MMALEncoding.I420, 90);

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

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

                            var timeout = DateTime.Now.AddSeconds(10);
                            while (DateTime.Now.CompareTo(timeout) < 0)
                            {
                                await _fixture.MMALCamera.ProcessAsync(_fixture.MMALCamera.Camera.StillPort);
                            }
                        }
            });
        }
Exemple #16
0
        public async Task RawVideoConvert()
        {
            TestHelper.BeginTest("RawVideoConvert");
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/videos/tests");

            using (var ffCaptureHandler = FFmpegCaptureHandler.RawVideoToAvi("/home/pi/videos/tests", "testing1234"))
                using (var vidEncoder = new MMALVideoEncoder())
                    using (var renderer = new MMALVideoRenderer())
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        var portConfig = new MMALPortConfig(MMALEncoding.H264, MMALEncoding.I420, 10, 25000000, null);

                        vidEncoder.ConfigureOutputPort(portConfig, ffCaptureHandler);

                        Fixture.MMALCamera.Camera.VideoPort.ConnectTo(vidEncoder);
                        Fixture.MMALCamera.Camera.PreviewPort.ConnectTo(renderer);

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

                        var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));

                        // Take video for 1 minute.
                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                        Fixture.CheckAndAssertFilepath("/home/pi/videos/tests/testing1234.avi");
                    }
        }
        public void TakeVideoSplit(string extension, MMALEncoding encodingType, MMALEncoding pixelFormat)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.InlineHeaders = true;

            AsyncContext.Run(async() =>
            {
                var vidCaptureHandler = new VideoStreamCaptureHandler("/home/pi/videos/tests/split_test", extension);

                TestHelper.CleanDirectory("/home/pi/videos/tests/split_test");

                using (var vidEncoder = new MMALVideoEncoder(vidCaptureHandler, new MMAL_RATIONAL_T(25, 1),
                                                             DateTime.Now.AddSeconds(30), new Split {
                    Mode = TimelapseMode.Second, Value = 15
                }))
                {
                    vidEncoder.ConfigureOutputPort(0, encodingType, pixelFormat, 10, 25000000);

                    //Create our component pipeline.
                    fixture.MMALCamera.Camera.VideoPort
                    .ConnectTo(vidEncoder);
                    fixture.MMALCamera.Camera.PreviewPort
                    .ConnectTo(new MMALVideoRenderer());

                    fixture.MMALCamera.ConfigureCameraSettings();

                    //2 files should be created from this test.
                    await fixture.MMALCamera.BeginProcessing(fixture.MMALCamera.Camera.VideoPort, vidEncoder);

                    Assert.True(Directory.GetFiles("/home/pi/videos/tests/split_test").Length == 2);
                }
            });
        }
Exemple #18
0
        public async Task TakeVideoAndStoreTimestamps()
        {
            TestHelper.BeginTest("Video - TakeVideoAndStoreTimestamps");
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/videos/tests");

            using (var vidCaptureHandler = new VideoStreamCaptureHandler("/home/pi/videos/tests", "h264", true))
                using (var preview = new MMALVideoRenderer())
                    using (var vidEncoder = new MMALVideoEncoder())
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        var portConfig = new MMALPortConfig(MMALEncoding.H264, MMALEncoding.I420, bitrate: MMALVideoEncoder.MaxBitrateLevel4);

                        vidEncoder.ConfigureOutputPort(portConfig, vidCaptureHandler);

                        // Create our component pipeline.
                        Fixture.MMALCamera.Camera.VideoPort
                        .ConnectTo(vidEncoder);
                        Fixture.MMALCamera.Camera.PreviewPort
                        .ConnectTo(preview);

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

                        CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));

                        // Record video for 15 seconds
                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                        Fixture.CheckAndAssertFilepath(vidCaptureHandler.GetFilepath());
                        Fixture.CheckAndAssertFilepath($"{vidCaptureHandler.Directory}/{vidCaptureHandler.CurrentFilename}.pts");
                    }
        }
        public void SetThenGetVideoStabilisation(bool vstab)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.VideoStabilisation = vstab;
            MMALCameraConfig.Reload();
            Assert.True(fixture.MMALCamera.Camera.GetVideoStabilisation() == vstab);
        }
        public void SetThenGetStatsPass(bool statsPass)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.StatsPass = statsPass;
            fixture.MMALCamera.ConfigureCameraSettings();
            Assert.True(fixture.MMALCamera.Camera.GetStatsPass() == statsPass);
        }
        public void SetThenGetDRC(MMAL_PARAMETER_DRC_STRENGTH_T drc)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.DrcLevel = drc;
            fixture.MMALCamera.ConfigureCameraSettings();
            Assert.True(fixture.MMALCamera.Camera.GetDRC() == drc);
        }
        public void SetThenGetFlips(MMAL_PARAM_MIRROR_T flips)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.Flips = flips;
            fixture.MMALCamera.ConfigureCameraSettings();
            Assert.True(fixture.MMALCamera.Camera.GetFlips() == flips);
        }
        public void SetThenGetImageFx(MMAL_PARAM_IMAGEFX_T imgFx)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.ImageFx = imgFx;
            fixture.MMALCamera.ConfigureCameraSettings();
            Assert.True(fixture.MMALCamera.Camera.GetImageFx() == imgFx);
        }
Exemple #24
0
        public void SetThenGetSensorMode(MMALSensorMode mode)
        {
            TestHelper.SetConfigurationDefaults();
            MMALCameraConfig.SensorMode = mode;

            _fixture.MMALCamera.ConfigureCameraSettings();
            Assert.True(_fixture.MMALCamera.Camera.GetSensorMode() == mode);
        }
        public void TakePictureTimelapse()
        {
            TestHelper.BeginTest("TakePictureTimelapse");
            TestHelper.SetConfigurationDefaults();

            AsyncContext.Run(async() =>
            {
                TestHelper.CleanDirectory("/home/pi/images/tests/split_tests");

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

                            imgEncoder.ConfigureOutputPort(0, MMALEncoding.JPEG, MMALEncoding.I420, 90);

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

                            CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
                            Timelapse tl = new Timelapse
                            {
                                Mode = TimelapseMode.Second,
                                CancellationToken = cts.Token,
                                Value             = 5
                            };

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

                            while (!tl.CancellationToken.IsCancellationRequested)
                            {
                                int interval = tl.Value * 1000;

                                await Task.Delay(interval);

                                await _fixture.MMALCamera.ProcessAsync(_fixture.MMALCamera.Camera.StillPort);
                            }

                            DirectoryInfo info = new DirectoryInfo(imgCaptureHandler.Directory);

                            if (info.Exists)
                            {
                                var files = info.EnumerateFiles();

                                Assert.True(files != null && files.Count() == 6);
                            }
                            else
                            {
                                Assert.True(false, $"File {imgCaptureHandler.GetFilepath()} was not created");
                            }
                        }
            });
        }
        public void SetThenGetRotation(int rotation, int expectedResult)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.Rotation = rotation;
            fixture.MMALCamera.ConfigureCameraSettings();

            Assert.True(fixture.MMALCamera.Camera.GetRotation() == expectedResult);
        }
        public void SetThenGetExposureMeteringMode(MMAL_PARAM_EXPOSUREMETERINGMODE_T expMetMode)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.ExposureMeterMode = expMetMode;
            fixture.MMALCamera.ConfigureCameraSettings();

            Assert.True(fixture.MMALCamera.Camera.GetExposureMeteringMode() == expMetMode);
        }
        public void SetThenGetAwbMode(MMAL_PARAM_AWBMODE_T awbMode)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.AwbMode = awbMode;
            fixture.MMALCamera.ConfigureCameraSettings();

            Assert.True(fixture.MMALCamera.Camera.GetAwbMode() == awbMode);
        }
        public void SetThenGetShutterSpeed(int shutterSpeed)
        {
            TestHelper.SetConfigurationDefaults();

            MMALCameraConfig.ShutterSpeed = shutterSpeed;
            fixture.MMALCamera.ConfigureCameraSettings();

            Assert.True(fixture.MMALCamera.Camera.GetShutterSpeed() == shutterSpeed);
        }
Exemple #30
0
        public async Task ChangeEncoderType()
        {
            TestHelper.BeginTest("Video - ChangeEncoderType");
            TestHelper.SetConfigurationDefaults();
            TestHelper.CleanDirectory("/home/pi/videos/tests");

            using (var vidCaptureHandler = new VideoStreamCaptureHandler("/home/pi/videos/tests", "h264"))
                using (var preview = new MMALVideoRenderer())
                    using (var vidEncoder = new MMALVideoEncoder(vidCaptureHandler))
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        var portConfig = new MMALPortConfig(MMALEncoding.MJPEG, MMALEncoding.I420, 25, 10, 25000000, null);

                        vidEncoder.ConfigureOutputPort(portConfig);

                        // Create our component pipeline.
                        Fixture.MMALCamera.Camera.VideoPort
                        .ConnectTo(vidEncoder);
                        Fixture.MMALCamera.Camera.PreviewPort
                        .ConnectTo(preview);

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

                        CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(20));

                        // Record video for 20 seconds
                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                        Fixture.CheckAndAssertFilepath(vidCaptureHandler.GetFilepath());
                    }

            using (var vidCaptureHandler = new VideoStreamCaptureHandler("/home/pi/videos/tests", "mjpeg"))
                using (var preview = new MMALVideoRenderer())
                    using (var vidEncoder = new MMALVideoEncoder(vidCaptureHandler))
                    {
                        Fixture.MMALCamera.ConfigureCameraSettings();

                        var portConfig = new MMALPortConfig(MMALEncoding.MJPEG, MMALEncoding.I420, 25, 10, 25000000, null);

                        vidEncoder.ConfigureOutputPort(portConfig);

                        // Create our component pipeline.
                        Fixture.MMALCamera.Camera.VideoPort
                        .ConnectTo(vidEncoder);
                        Fixture.MMALCamera.Camera.PreviewPort
                        .ConnectTo(preview);

                        CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(20));

                        // Record video for 20 seconds
                        await Fixture.MMALCamera.ProcessAsync(Fixture.MMALCamera.Camera.VideoPort, cts.Token);

                        Fixture.CheckAndAssertFilepath(vidCaptureHandler.GetFilepath());
                    }
        }