Esempio n. 1
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);
            }
        }
Esempio n. 2
0
 //退出时关闭相机
 public void CamClose(TIS.Imaging.ICImagingControl icImagingControl1)
 {
     if (icImagingControl1.DeviceValid)
     {
         icImagingControl1.LiveStop();
     }
 }
Esempio n. 3
0
        //保存图片
        public void SaveImage(TIS.Imaging.ICImagingControl icImagingControl1, string filename)
        {
            icImagingControl1.LiveStop();
            icImagingControl1.LiveStart();

            icImagingControl1.ImageActiveBuffer.SaveImage(filename + ".bmp");
        }
        private void btnSelectDevice_Click(object sender, RoutedEventArgs e)
        {
            _ic.LiveStop();

            _ic.ShowDeviceSettingsDialog();

            if (_ic.DeviceValid)
            {
                _ic.LiveStart();
            }
        }
Esempio n. 5
0
 //>>
 //
 // cmdStopButton_Click
 //
 // Stop the AVI capturing.
 //
 private void cmdStopButton_Click(object sender, System.EventArgs e)
 {
     if (_ImagingControl.DeviceValid)
     {
         _ImagingControl.LiveStop();
         _ImagingControl.Sink   = _savedSink;
         _savedSink             = null;
         cmdStartButton.Enabled = true;
         cmdStopButton.Enabled  = false;
     }
 }
Esempio n. 6
0
 public bool Close()
 {
     try
     {
         if (m_ImageControl.LiveVideoRunning)
         {
             m_ImageControl.LiveStop();
         }
         //  IsConnected = false;
         return(true);
     }
     catch (Exception ex)
     {
         Trace.WriteLine("YMJ Close fail " + ex.Message);
         return(false);
     }
 }
Esempio n. 7
0
 //关闭相机
 public void StopLiveVideo(TIS.Imaging.ICImagingControl icImagingControl1)
 {
     icImagingControl1.LiveStop();
 }