コード例 #1
0
 //触发极化
 public void TriggerPolary(TIS.Imaging.ICImagingControl icImagingControl1)
 {
     //极化初始化
     TriPolarity = (TIS.Imaging.VCDSwitchProperty)icImagingControl1.VCDPropertyItems.FindInterface(TIS.Imaging.VCDIDs.VCDID_TriggerMode + ":" +
                                                                                                   TIS.Imaging.VCDIDs.VCDElement_TriggerPolarity + ":" + TIS.Imaging.VCDIDs.VCDInterface_Switch);
     TriPolarity.Switch = false;
 }
コード例 #2
0
        /// <summary>
        /// 打开相机
        /// </summary>
        /// <param name="strSN">相机ID号</param>
        /// <returns>成功返回true,失败返回false</returns>
        ///
        public bool  Open(string strSN)
        {
            try
            {
                string tempSN = string.Empty;
                m_ImageControl = new ICImagingControl();
                foreach (Device dev in m_ImageControl.Devices)
                {
                    if (dev.GetSerialNumber(out tempSN))
                    {
                        if (strSN == tempSN)//判断是否等于指定相机序号
                        {
                            m_ImageControl.Device = dev.Name;
                            break;
                        }
                    }
                }
                if (!m_ImageControl.DeviceValid)
                {
                    throw new Exception("没有找到相机,是否SN号有误!");
                }
                if (m_ImageControl.LiveVideoRunning)
                {
                    m_ImageControl.LiveStop();
                }
                m_ImageControl.MemoryCurrentGrabberColorformat = TIS.Imaging.ICImagingControlColorformats.ICY8;
                float[] Frame = m_ImageControl.DeviceFrameRates;
                m_ImageControl.DeviceFrameRate = Frame[0];
                VCDProp = TIS.Imaging.VCDHelpers.VCDSimpleModule.GetSimplePropertyContainer(m_ImageControl.VCDPropertyItems);

                //m_ImageControl.DeviceListChangedExecutionMode = TIS.Imaging.EventExecutionMode.Invoke;
                //m_ImageControl.DeviceLostExecutionMode = TIS.Imaging.EventExecutionMode.AsyncInvoke;
                //m_ImageControl.ImageAvailableExecutionMode = TIS.Imaging.EventExecutionMode.Invoke;

                m_ImageControl.LiveCaptureContinuous = true;
                m_ImageControl.LiveDisplayDefault    = false;
                m_ImageControl.ImageAvailable       += ImageCallBack;
                m_byMonoBuffer = new byte[m_nWidth * m_nHeight];
                m_ImageControl.LiveStart();
                TrigEnableSwitch = (TIS.Imaging.VCDSwitchProperty)m_ImageControl.VCDPropertyItems.FindInterface(TIS.Imaging.VCDIDs.VCDID_TriggerMode + ":" +
                                                                                                                TIS.Imaging.VCDIDs.VCDElement_Value + ":" + TIS.Imaging.VCDIDs.VCDInterface_Switch);

                TrigEnableSwitch.Switch = true;


                m_ImageControl.LiveStop();

                //TrigEnableSwitch.Switch = false;
                //  m_ImageControl.DeviceTrigger = false;  Imagecamera cannot set trigger while openning
                bIsConnected = true;
                //IsConnected = true;
                return(true);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("YMJ Init fail " + ex.Message);
                return(false);
            }
        }
コード例 #3
0
 //频闪使能
 public void StrobeEnable(TIS.Imaging.ICImagingControl icImagingControl1)
 {
     StrobeSwitch = (TIS.Imaging.VCDSwitchProperty)icImagingControl1.VCDPropertyItems.FindInterface(TIS.Imaging.VCDIDs.VCDID_Strobe + ":"
                                                                                                    + TIS.Imaging.VCDIDs.VCDElement_Value + ":" + TIS.Imaging.VCDIDs.VCDInterface_Switch);
     if (StrobeSwitch != null)
     {
         StrobeSwitch.Switch = true;//频闪使能
     }
 }
コード例 #4
0
 //触发使能
 public void TriEnable(TIS.Imaging.ICImagingControl icImagingControl1)
 {
     TrigEnableSwitch = (TIS.Imaging.VCDSwitchProperty)icImagingControl1.VCDPropertyItems.FindInterface(TIS.Imaging.VCDIDs.VCDID_TriggerMode + ":" +
                                                                                                        TIS.Imaging.VCDIDs.VCDElement_Value + ":" + TIS.Imaging.VCDIDs.VCDInterface_Switch);
     if (TrigEnableSwitch != null)
     {
         TrigEnableSwitch.Switch = true;//触发使能
     }
 }
コード例 #5
0
        public bool SetCamParam(CamParam eParam, string strParamValue)
        {
            try
            {
                switch (eParam)
                {
                case CamParam.Exposure:
                    //VCDProp.RangeValue[VCDIDs.VCDID_Exposure] = Convert.ToInt32(strParamValue);
                    ExposureSwith        = (TIS.Imaging.VCDSwitchProperty)m_ImageControl.VCDPropertyItems.FindInterface(VCDIDs.VCDID_Exposure + ":" + VCDIDs.VCDElement_Auto + ":" + VCDIDs.VCDInterface_Switch);
                    ExposureSwith.Switch = false;    //关闭自动曝光
                    //绝对曝光对象初始化
                    ExposureAbsoluteValue = (TIS.Imaging.VCDAbsoluteValueProperty)m_ImageControl.VCDPropertyItems.FindInterface(VCDIDs.VCDID_Exposure + ":" + VCDIDs.VCDElement_Value + ":" + VCDIDs.VCDInterface_AbsoluteValue);
                    double time = 1 / Convert.ToDouble(strParamValue);
                    if (time <= ExposureAbsoluteValue.RangeMin)
                    {
                        ExposureAbsoluteValue.Value = ExposureAbsoluteValue.RangeMin;
                    }
                    else if (time >= ExposureAbsoluteValue.RangeMax)
                    {
                        ExposureAbsoluteValue.Value = ExposureAbsoluteValue.RangeMax;
                    }
                    else
                    {
                        ExposureAbsoluteValue.Value = time;
                    }

                    break;

                case CamParam.FrameRate:
                    //m_ImageControl.DeviceFrameRate = float.Parse(strParamValue);
                    break;

                case CamParam.Gain:
                    //VCDProp.RangeValue[VCDIDs.VCDID_Gain] = Convert.ToInt32(strParamValue);
                    GainSwith        = (TIS.Imaging.VCDSwitchProperty)m_ImageControl.VCDPropertyItems.FindInterface(VCDIDs.VCDID_Gain + ":" + VCDIDs.VCDElement_Auto + ":" + VCDIDs.VCDInterface_Switch);
                    GainSwith.Switch = false;    //关闭自动增益
                    //绝对增益对象初始化
                    GainAbsoluteValue = (TIS.Imaging.VCDAbsoluteValueProperty)m_ImageControl.VCDPropertyItems.FindInterface(VCDIDs.VCDID_Gain + ":" + VCDIDs.VCDElement_Value + ":" + VCDIDs.VCDInterface_AbsoluteValue);
                    double GValue = Convert.ToDouble(strParamValue) / 1000;
                    if (GValue <= GainAbsoluteValue.RangeMin)
                    {
                        GainAbsoluteValue.Value = GainAbsoluteValue.RangeMin;
                    }
                    else if (GValue >= GainAbsoluteValue.RangeMax)
                    {
                        GainAbsoluteValue.Value = GainAbsoluteValue.RangeMax;
                    }
                    else
                    {
                        GainAbsoluteValue.Value = GValue;
                    }
                    break;

                default:
                    break;
                }
                return(true);
            }
            catch (Exception ex)
            {
                //    m_strLastErr = ex.Message;
                return(false);
            }
        }