/// <summary>
        /// Disable the camera automatics for gain and exposure. Set exposure time to at least 0.25 seconds.
        /// </summary>
        /// <param name="value">Automatics on and off. True = on, False = off</param>
        private void prepareProperties(bool value)
        {
            VCDSwitchProperty exposureauto = (VCDSwitchProperty)icImagingControl1.VCDPropertyItems.FindInterface(VCDGUIDs.VCDID_Exposure, VCDGUIDs.VCDElement_Auto);

            if (exposureauto != null)
            {
                exposureauto.Switch = value;
            }

            VCDSwitchProperty gainauto = (VCDSwitchProperty)icImagingControl1.VCDPropertyItems.FindInterface(VCDGUIDs.VCDID_Gain, VCDGUIDs.VCDElement_Auto);

            if (gainauto != null)
            {
                gainauto.Switch = value;
            }

            if (!value)
            {
                VCDAbsoluteValueProperty exposureTime = (VCDAbsoluteValueProperty)icImagingControl1.VCDPropertyItems.FindInterface(VCDGUIDs.VCDID_Exposure,
                                                                                                                                   VCDGUIDs.VCDElement_Value, VCDGUIDs.VCDInterface_AbsoluteValue);
                if (exposureTime != null)
                {
                    exposureTime.Value = Math.Min(exposureTime.RangeMax, 0.25);
                }
            }
        }
        protected override void GetCameraSettingData()
        {
            try
            {
                //关闭自动曝光
                VCDSwitchProperty exposureAuto = (VCDSwitchProperty)camera.VCDPropertyItems.FindInterface(
                    VCDIDs.VCDID_Exposure + ":" +
                    VCDIDs.VCDElement_Auto + ":" +
                    VCDIDs.VCDInterface_Switch);
                exposureAuto.Switch = false;

                //关闭自动增益
                VCDSwitchProperty gainSwith = (VCDSwitchProperty)camera.VCDPropertyItems.FindInterface(
                    VCDIDs.VCDID_Gain + ":" +
                    VCDIDs.VCDElement_Auto + ":" +
                    VCDIDs.VCDInterface_Switch);
                gainSwith.Switch = false;


                //long max, min, cur;
                gainMin  = GainAbsoluteValue.RangeMin;
                gainMax  = GainAbsoluteValue.RangeMax;
                gainCur  = GainAbsoluteValue.Value;
                gainUnit = "";

                shuterUnit = "us";


                shuterMin = (long)ExposureAbsoluteValue.RangeMin * exposureSocle;
                shuterMax = (long)ExposureAbsoluteValue.RangeMax * exposureSocle;
                shuterCur = (long)ExposureAbsoluteValue.Value * exposureSocle;


                triggerDelayAbsMin = TriggerDelayTime.RangeMin;
                triggerDelayAbsMax = TriggerDelayTime.RangeMax;
                triggerDelayAbs    = TriggerDelayTime.Value;

                lineDebouncerTimeAbsMin = TriggerDebounceTime.RangeMin;
                lineDebouncerTimeAbsMax = TriggerDebounceTime.RangeMax;
                lineDebouncerTimeAbs    = TriggerDebounceTime.Value;
            }
            catch (Exception ex)
            {
                Util.WriteLog(this.GetType(), ex);
                Util.Notify("相机设置信息获取异常");
            }
        }
示例#3
0
        public SoftwareTrigger()
        {
            ic.LiveCaptureContinuous = true;  //Call ImageAvailable event for new images.
            ic.LiveCaptureLastImage  = false; // Do not save an image on live stop.

            // Add the ImageAvailable handler to the IC Imaging Control object.
            ic.ImageAvailable += new EventHandler <ICImagingControl.ImageAvailableEventArgs>(ic_ImageAvailable);

            ic.ShowDeviceSettingsDialog(); // Select a video capture device
            if (!ic.DeviceValid)
            {
                return;
            }

            // Query the trigger mode property for enabling the trigger mode
            VCDSwitchProperty TriggerMode = (VCDSwitchProperty)ic.VCDPropertyItems.FindInterface(VCDIDs.VCDID_TriggerMode, VCDIDs.VCDElement_Value, VCDIDs.VCDInterface_Switch);

            if (TriggerMode == null)
            {
                return;
            }

            // If trigger mode is available, query the software trigger property
            VCDButtonProperty SoftwareTrigger = (VCDButtonProperty)ic.VCDPropertyItems.FindInterface(VCDIDs.VCDID_TriggerMode, VCDIDs.VCDElement_SoftwareTrigger, VCDIDs.VCDInterface_Button);

            if (SoftwareTrigger == null)
            {
                return;
            }

            TriggerMode.Switch = true; // Enable trigger mode,

            ic.LiveStart();            // start the camera. No images are streamed, because trigger mode is enabled
            System.Threading.Thread.Sleep(1000);
            SoftwareTrigger.Push();    // Do a software trigger.
            System.Threading.Thread.Sleep(1000);
            SoftwareTrigger.Push();    // Do another software trigger.
            System.Threading.Thread.Sleep(1000);

            ic.LiveStop();              // Stop live video.
            TriggerMode.Switch = false; // Disable trigger mode again.
        }