コード例 #1
0
 public override bool Open()
 {
     try
     {
         m_FrameListener = new pfnCameraGrabberFrameListener(CameraGrabberFrameListener);
         //图像镜像设置
         MvApi.CameraSetMirror(m_hCamera, 0, 0);
         MvApi.CameraSetMirror(m_hCamera, 1, 0);
         MvApi.CameraGrabber_SetFrameListener(m_Grabber, m_FrameListener, IntPtr.Zero);
         ContinuousShotStop();
         GetCameraSettingData();
         MvApi.CameraGrabber_StartLive(m_Grabber);
         MvApi.CameraSetOutPutIOMode(m_hCamera, 0, (int)emCameraGPIOMode.IOMODE_GP_OUTPUT);
         MvApi.CameraSetIOState(m_hCamera, 0, 1);
         // Reset the stopwatch used to reduce the amount of displayed images. The camera may acquire images faster than the images can be displayed
         //stopWatch.Reset();
         IsLink = true;
     }
     catch (Exception ex)
     {
         Util.WriteLog(this.GetType(), ex);
         Util.Notify("相机打开出现异常");
         throw ex;
     }
     return(true);
 }
コード例 #2
0
        public override bool Open()
        {
            try
            {
                m_FrameListener = new pfnCameraGrabberFrameListener(CameraGrabberFrameListener);
                m_CameraConnectionStatusCallback = new CAMERA_CONNECTION_STATUS_CALLBACK(CameraConnectionStatusCallback);
                //图像镜像设置,第三个参数代表是否镜像。
                //MvApi.CameraSetMirror(m_hCamera, 0, 1);                    //Collumn镜像
                MvApi.CameraSetMirror(m_hCamera, 1, 1);                      //Row镜像
                MvApi.CameraGrabber_SetFrameListener(m_Grabber, m_FrameListener, IntPtr.Zero);
                MvApi.CameraSetConnectionStatusCallback(m_hCamera, m_CameraConnectionStatusCallback, IntPtr.Zero);
                ContinuousShotStop();
                GetCameraSettingData();
                MvApi.CameraGrabber_StartLive(m_Grabber);
                MvApi.CameraSetOutPutIOMode(m_hCamera, 0, (int)emCameraGPIOMode.IOMODE_GP_OUTPUT);
                MvApi.CameraSetIOState(m_hCamera, 0, 1);
                // Reset the stopwatch used to reduce the amount of displayed images. The camera may acquire images faster than the images can be displayed
                //stopWatch.Reset();
                IsLink = true;
            }
            catch (Exception ex)
            {
                Util.WriteLog(this.GetType(), ex);
                Util.Notify("相机打开出现异常");
                return(false);

                throw ex;      //不能随便屏蔽,否则上层接收不到异常,会接着执行函数下面原先不应该执行的部分。
            }
            return(true);
        }