Пример #1
0
        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");
        }
Пример #2
0
 private static void SetParameterToInvalid(string name, object value)
 {
     try
     {
         cam.SetParameter(name, value);
         log.ErrorFormat("Setting {0} to \"{1}\" should have thrown an Exception!", name, value);
     }
     catch (ArgumentException)
     {
         log.InfoFormat("Setting {0} to \"{1}\" expectedly caused an error.", name, value);
     }
     catch (ParameterNotSupportedException)
     {
         log.ErrorFormat("Setting {0} to \"{1}\" caused an unexpected error." + Environment.NewLine
                         + "Probably the camera does not support this parameter.", name, value);
         return;
     }
     LogParameterValue(name);
 }
Пример #3
0
        /// <summary>
        /// Creates instances of all currently loaded camera implementations.
        /// Optionally finds all camera implementations in local and SDK folder first.
        /// </summary>
        /// <param name="scanForCameraDLLs">If enabled, all assemblies (.DLL files) in the local folder and the MetriCam2 SDK path are scanned.</param>
        /// <remarks>The MetriCam2 SDK path is read from the registry.</remarks>
        public void InitializeCameras(bool scanForCameraDLLs)
        {
            log.DebugFormat("InitializeCameras({0})", scanForCameraDLLs);
            if (scanForCameraDLLs)
            {
                log.Debug("Scanning for camera DLLs");
                LoadLocalDirectoryAssemblies();
                LoadRegistryDirectoryAssemblies();
            }

            AvailableCameras.Clear();
            foreach (string cameraTypeName in AvailableCameraTypeNames)
            {
                try
                {
                    Camera cam = GetCameraInstanceByName(cameraTypeName);
                    AvailableCameras.Add(cam);
                }
                catch (Exception ex)
                {
                    log.InfoFormat("Camera with TypeName '{0}' was not added due to an exception: {1}", cameraTypeName, ex.Message);
                }
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            log.SetLogLevel(log4net.Core.Level.Info);

            cam = new UEyeCamera(); // Change this type if you want to test your camera implementation.
            List <Camera.ParamDesc> allParameters;

            log.Info("Testing " + cam.Name);

            allParameters = cam.GetParameters();
            log.InfoFormat("Camera {0} has {1} parameter(s):\n{2}", cam.Name, allParameters.Count, Camera.ParamDesc.ToString(allParameters));


            // TEST: setting a writable parameter while disconnected
            if (cam is UEyeCamera)
            {
                TestSetParameterSuccess("TriggerMode", "SOFTWARE");
            }

            // TEST: setting a non-writable parameter while disconnected
            TestSetParameterDisconnected("Gain", 40);

            cam.Connect();

            log.InfoFormat("Connected {0} camera with S/N \"{1}\".", cam.Name, cam.SerialNumber);

            allParameters = cam.GetParameters();
            log.InfoFormat("Camera {0} has {1} parameter(s):\n{2}", cam.Name, allParameters.Count, Camera.ParamDesc.ToString(allParameters));

            if (cam is UEyeCamera)
            {
                // TEST: setting a list parameter to a valid value.
                TestSetParameterSuccess("TriggerMode", "HARDWARE");

                // TEST: setting a list parameter to an invalid value.
                TestSetParameterToInvalid("TriggerMode", "---");
            }

            // TEST: setting a range parameter to a valid value.
            TestSetParameterSuccess("Gain", 40);

            // TEST: setting a range parameter to an invalid value.
            TestSetParameterToInvalid("Gain", 305);

            // TEST: setting an Auto* parameter to a valid value
            TestSetParameterSuccess("AutoGain", true);

            // TEST: setting an Auto* parameter to an invalid value
            TestSetParameterToInvalid("AutoGain", 13);

            Dictionary <string, object> params1 = new Dictionary <string, object>();

            params1["Gain"]     = 40;
            params1["AutoGain"] = true;
            if (cam is UEyeCamera)
            {
                params1["TriggerMode"] = "FREERUN";
            }
            cam.SetParameters(params1);
            List <Camera.ParamDesc> allParameters1 = cam.GetParameters();

            log.InfoFormat("Camera {0} has {1} parameter(s):\n{2}", cam.Name, allParameters1.Count, Camera.ParamDesc.ToString(allParameters1));

            Dictionary <string, object> params2 = new Dictionary <string, object>();

            params2["Gain"]     = 40;
            params2["AutoGain"] = false;
            if (cam is UEyeCamera)
            {
                params2["TriggerMode"] = "FREERUN";
            }
            cam.SetParameters(params2);
            List <Camera.ParamDesc> allParameters2 = cam.GetParameters();

            log.InfoFormat("Camera {0} has {1} parameter(s):\n{2}", cam.Name, allParameters2.Count, Camera.ParamDesc.ToString(allParameters2));

            cam.Disconnect();

            log.Info("Press any key to close.");
            Console.ReadKey();
        }