示例#1
0
        public override bool Init(HardwareData hardeareData)
        {
            bInitOk = false;
            #region TCP/IP
            if (!(null == _aca500M_Camera))
            {
                _aca500M_Camera.Dispose();
            }
            try
            {
                aca500M_Camera = new BP.Camera(cameraData.SerialNumber);
                GetParameter();
                if (!_aca500M_Camera.IsOpen)
                {
                    _aca500M_Camera.Open();
                }
                if (!_aca500M_Camera.StreamGrabber.IsGrabbing)
                {
                    _aca500M_Camera.StreamGrabber.Start(cameraData.maxPictureNumber, GrabStrategy.OneByOne, GrabLoop.ProvidedByUser);
                    bAsync = false;
                }


                bInitOk = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
            return(bInitOk);
        }
示例#2
0
        /// <summary>
        /// 关闭相机,停止抓取相机并断开相机连接
        /// </summary>
        public override bool CloseCamera()
        {
            try
            {
#if (SDK)
                if (g_BaseParCamera.BlUsingTrigger)
                {
                    //关闭软触发
                }
                if (g_Camera != null && g_Camera.IsOpen && g_Camera.StreamGrabber.IsGrabbing)
                {
                    g_Camera.StreamGrabber.Stop();
                    g_Camera.Close();
                    g_Camera.Dispose();
                    g_Camera = null;
                }
#endif
                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }
示例#3
0
        public override void Close()
        {
            try
            {
                IsLink = false;
                // Reset the stopwatch.
                //stopWatch.Reset();
                if (g_camera != null)
                {
                    // Stop the grabbing.
                    g_camera.StreamGrabber.Stop();
                    // Close the connection to the camera device.
                    g_camera.Close();
                    g_camera.Dispose();
                    g_camera = null;
                }

                if (m_latestFrameAddress != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(m_latestFrameAddress);
                    m_latestFrameAddress = IntPtr.Zero;
                }
            }
            catch (Exception ex)
            {/*
              * Util.WriteLog(this.GetType(), ex);
              * Util.Notify("相机关闭异常");*/
            }
        }
示例#4
0
文件: CameraBasler.cs 项目: Gz1d/Gz
 public override bool CloseCamera()
 {
     camera1.StreamGrabber.Stop();
     camera1.Close();
     camera1.Dispose();
     camera1 = null;
     return(true);
 }
示例#5
0
 public short Close()
 {
     if (camera == null)
     {
         return(-1);
     }
     else
     {
         camera.Close();
         camera.Dispose();
         camera = null;
         return(0);
     }
 }
示例#6
0
 public override void Close()
 {
     try
     {
         objDev.Close();
         objDev.Dispose();
         if (latestFrameAddress != null)
         {
             Marshal.FreeHGlobal(latestFrameAddress);
             latestFrameAddress = IntPtr.Zero;
         }
     }
     catch (Exception e)
     {
         ShowException(e);
     }
 }
示例#7
0
        /// <summary>
        /// 关闭相机
        /// </summary>
        /// <returns></returns>
        public override bool DoClose()
        {
            bool rt = false;

            try
            {
                if (_device != null)
                {
                    SetFreeRun();
                    _device.Close();
                    _device.Dispose();
                    rt = true;
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:巴斯勒相机关闭失败!\n:{0}",
                                                         "设备未连接"));
                    }
                }
            }
            catch (System.Exception ex)
            {
                if (DriverExceptionDel != null)
                {
                    DriverExceptionDel(string.Format("错误:巴斯勒相机关闭失败!\n错误描述:{0}",
                                                     ex.Message));
                }
            }
            finally
            {
            }

            return(rt);
        }