コード例 #1
0
        //保存图片
        public void SaveImage(TIS.Imaging.ICImagingControl icImagingControl1, string filename)
        {
            icImagingControl1.LiveStop();
            icImagingControl1.LiveStart();

            icImagingControl1.ImageActiveBuffer.SaveImage(filename + ".bmp");
        }
コード例 #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
        private void btnSelectDevice_Click(object sender, RoutedEventArgs e)
        {
            _ic.LiveStop();

            _ic.ShowDeviceSettingsDialog();

            if (_ic.DeviceValid)
            {
                _ic.LiveStart();
            }
        }
コード例 #4
0
 //
 // cmdStartButton_Click
 //
 // Start the AVI capturing.
 //
 //<<StartCapture
 private void cmdStartButton_Click(object sender, System.EventArgs e)
 {
     if (_ImagingControl.DeviceValid)
     {
         _savedSink           = _ImagingControl.Sink;
         _ImagingControl.Sink = new MediaStreamSink((AviCompressor)CodecBox.SelectedItem, edtAVIFile.Text);
         _ImagingControl.LiveStart();
         cmdStartButton.Enabled = false;
         cmdStopButton.Enabled  = true;
     }
 }
コード例 #5
0
 //开启相机
 public void StartLiveVideo(TIS.Imaging.ICImagingControl icImagingControl1)
 {
     icImagingControl1.LiveStart();
 }