Esempio n. 1
0
        public void cannot_use_factory_if_is_not_initialised()
        {
            using var module = new PiTopModule(new DummyGpioController());
            var action = new Action(() =>
                module.GetOrCreateCamera<FileSystemCamera>(new DirectoryInfo(Path.GetTempPath()))
            );

            action.Should().Throw<InvalidOperationException>()
                .Which
                .Message
                .Should()
                .Match("Cannot find a factory if type PiTop.Abstractions.IConnectedDeviceFactory<PiTop.Camera.FileSystemCameraSettings, PiTop.Camera.FileSystemCamera>, make sure to configure the module calling UseCamera first.");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            using var module = new PiTopModule()
                               .UseCamera();

            var count = OpenCvCamera.GetCameraCount();

            Console.WriteLine($"Found {count} cameras available");

            var camera = module.GetOrCreateCamera <OpenCvCamera>(0);

            var file = new FileInfo("./test.png");

            var frame = camera.GetFrameAsMat();

            frame.SaveImage(file.FullName);

            module.DisposeDevice(camera);

            Console.WriteLine($"Dumping frame at {file.FullName}");
        }
Esempio n. 3
0
 public static T GetOrCreateCamera <T>(this PiTopModule module, DirectoryInfo directory, string imageFileSearchPattern = "*.png") where T : FileSystemCamera
 {
     return(module.GetOrCreateCamera <T>(
                new FileSystemCameraSettings(directory, imageFileSearchPattern)));
 }