static void Main(string[] args) { log.SetLogLevel(log4net.Core.Level.Debug); SVS cam = new SVS(); try { cam.Connect(); } catch (MetriCam2.Exceptions.ConnectionFailedException e) { log.FatalFormat("Could not connect to camera: {0}", e.Message); return; } log.InfoFormat("Camera connected: {0} (S/N {1})", cam.Name, cam.SerialNumber); //log.DebugFormat("activating software trigger (current setting: {0})", cam.AcquisitionMode); cam.SetParameter("AutoGain", false); //log.DebugFormat("activated software trigger (current setting: {0})", cam.AcquisitionMode); cam.SetParameter("Exposure", 5.0f * 1000f); log.DebugFormat("exposure: {0}", cam.Exposure); log.DebugFormat("activating software trigger (current setting: {0})", cam.AcquisitionMode); cam.AcquisitionMode = MetriCam2.Cameras.Internal.SVS.GigeApi.ACQUISITION_MODE.ACQUISITION_MODE_SOFTWARE_TRIGGER; log.DebugFormat("activated software trigger (current setting: {0})", cam.AcquisitionMode); Console.WriteLine("Press Esc to quit. Press any other key to capture a frame."); while (true) { ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.Escape) { break; } cam.Update(); log.InfoFormat("Updated camera. Frame number is {0}", cam.FrameNumber); //cam.CalcChannel() } cam.Disconnect(); log.Info("Camera disconnected"); }
// Connect to SVS private bool Connect(string host) { bool result = true; try { svs.Connect(host); svs.EnableFailsafeMode(0, 0); svs.FlipVideo(false); svs.SetQuality(7); svs.SetResolution(SRV1.VideoResolution.Small); // start left camera SRV1Camera leftCamera = svs.GetCamera(SVS.Camera.Left); leftCameraPlayer.VideoSource = leftCamera; leftCameraPlayer.Start( ); // start right camera SRV1Camera rightCamera = svs.GetCamera(SVS.Camera.Right); rightCameraPlayer.VideoSource = rightCamera; rightCameraPlayer.Start( ); versionLabel.Text = svs.GetVersion( ); receivedFirstDrivingCommand = false; // reset statistics statIndex = statReady = 0; // start timer timer.Start( ); } catch { result = false; Disconnect( ); } return(result); }