예제 #1
0
        public void TestStreamFrame()
        {
            var ret = _client.RequestCameraParameters(new CameraParametersRequest()
            {
                Params = new CameraParameters()
                {
                    NumFrames = 1, ExposureTime = 1000000, Gain = 10, FrameRate = 30
                }
            });

            Assert.IsNull(ret.Error);

            var stream = _client.RequestFrameStream();

            for (int i = 0; i < 5; i++)
            {
                stream.RequestStream.WriteAsync(new CameraAcquisitionRequest()).Wait();
                TestContext.WriteLine($"{DateTime.Now} Requested");
                stream.ResponseStream.MoveNext(CancellationToken.None).Wait();
                TestContext.WriteLine($"{DateTime.Now} Received");

                var current = stream.ResponseStream.Current;
                Assert.IsNull(current.Error);
                var image = current.Images;

                using (var f = File.Open($"{i}.png", FileMode.OpenOrCreate))
                {
                    image[0].WriteTo(f);
                }
                Task.Delay(500).Wait();
            }
        }
예제 #2
0
        public void TestConfigureCamera()
        {
            double exposureTime = 45.0;
            int    numFrames    = 1;
            int    gain         = 10;
            double frameRate    = 390.0;

            StartVimbaAndShutDown(() =>
            {
                _client.RequestCameraConnection(
                    new CameraConnectionRequest()
                {
                    CameraID = CameraId, Command = ConnectionCommands.Connect
                });

                var response = _client.RequestCameraParameters(new CameraParametersRequest()
                {
                    Write  = true,
                    Params = new CameraParameters()
                    {
                        ExposureTime = exposureTime,
                        NumFrames    = numFrames,
                        Gain         = gain,
                        FrameRate    = frameRate
                    }
                });
                Assert.IsNull(response.Error);

                // read out
                response = _client.RequestCameraParameters(new CameraParametersRequest()
                {
                    Write = false
                });
                Assert.IsNull(response.Error);
                Assert.IsTrue(Math.Abs(response.Params.ExposureTime - exposureTime) < 1);
                Assert.IsTrue(Math.Abs(response.Params.FrameRate - frameRate) < 1);
                Assert.IsTrue(Math.Abs(response.Params.Gain - gain) < 1);
                Assert.AreEqual(response.Params.NumFrames, numFrames);
            });
        }