Пример #1
0
        protected override bool DoGetCameraConnectedState(out bool isConnected)
        {
            bool rt = false; isConnected = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    status      = MVSDK.MvApi.CameraConnectTest(_deviceRef);
                    rt          = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    isConnected = rt;
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机获取连接状态失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch (Exception ex)
            {
                if (DriverExceptionDel != null)
                {
                    DriverExceptionDel(string.Format("错误:迈德威视相机获取连接状态失败!\n错误描述:{0}", ex.Message));
                }
            }
            return(rt);
        }
Пример #2
0
        /// <summary>
        /// 方法:设置触发信号边缘
        /// [注:用于触发源为硬触发]
        /// </summary>
        /// <param name="dege">边缘信号</param>
        /// <returns></returns>
        protected override bool DoSetTriggerActivation(ProCommon.Communal.EffectiveSignal edge)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    switch (edge)
                    {
                    case ProCommon.Communal.EffectiveSignal.FallEdge:
                    {
                        status = MVSDK.MvApi.CameraSetExtTrigSignalType(_deviceRef, 1);        //MVSDK.emExtTrigSignal.EXT_TRIG_TRAILING_EDGE=1
                    }
                    break;

                    case ProCommon.Communal.EffectiveSignal.RaiseEdge:
                    {
                        status = MVSDK.MvApi.CameraSetExtTrigSignalType(_deviceRef, 0);          //MVSDK.emExtTrigSignal.EXT_TRIG_LEADING_EDGE=0
                    }
                    break;

                    default:
                        break;
                    }

                    rt = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置触发信号边沿失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置设备采集信号边沿失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #3
0
        /// <summary>
        /// 设置相机输出信号
        /// </summary>
        /// <param name="onOff"></param>
        /// <param name="idx"></param>
        /// <returns></returns>
        protected override bool DoSetOutPut(int idx, bool onOff)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;

            try
            {
                if (_deviceRef > 0)
                {
                    //SDK:导通--低电平--0;断开--高电平--1
                    uint level = onOff ? (uint)0 : 1;

                    //设置输出口模式为通用型输出模式-3  闪光灯输出-1
                    status = MVSDK.MvApi.CameraSetOutPutIOMode(_deviceRef, idx, 3);

                    rt = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;

                    if (rt)
                    {
                        status = MVSDK.MvApi.CameraSetIOState(_deviceRef, idx, level);
                        rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    }

                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置触发延迟失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                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);
        }
Пример #4
0
        public override bool DoClose()
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    status = MVSDK.MvApi.CameraStop(_deviceRef);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (rt)
                    {
                        status = MVSDK.MvApi.CameraUnInit(_deviceRef);
                        rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                        if (!rt)
                        {
                            if (DriverExceptionDel != null)
                            {
                                DriverExceptionDel(string.Format("错误:迈德威视相机停止采集失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                            }
                        }
                    }
                    else
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机关闭失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机关闭设备失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #5
0
        protected override bool DoSetExposureTime(float exposuretime)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    //SDK--使能自动曝光-1,关闭自动曝光--0
                    status = MVSDK.MvApi.CameraSetAeState(_deviceRef, 0);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;

                    if (rt)
                    {
                        //SDK曝光时间单位为微秒,转换成微秒
                        exposuretime *= 1000;
                        status        = MVSDK.MvApi.CameraSetExposureTime(_deviceRef, exposuretime);
                        rt            = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    }

                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置曝光时间失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置曝光时间失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #6
0
        protected override bool DoRegisterExceptionCallBack()
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                rt = true;
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #7
0
        protected override bool DoGetInPut(int lineIdx, out bool onOff)
        {
            bool rt = false; onOff = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    uint puState = 0;
                    status = MVSDK.MvApi.CameraGetIOState(_deviceRef, lineIdx, ref puState);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;

                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机获取输入端口状态失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                    else
                    {
                        //SDK:导通--低电平--0--逻辑True,断开--高电平--1--逻辑false
                        onOff = (puState == 0) ? true : false;
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机获取输入端口状态失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #8
0
        public override bool DoRegisterExceptionCallBack()
        {
            bool rt = false;

#pragma warning disable CS0219 // The variable 'status' is assigned but its value is never used
            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
#pragma warning restore CS0219 // The variable 'status' is assigned but its value is never used
            try
            {
                rt = true;
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #9
0
        public override bool GetExposureTime(out float exposuretime)
        {
            exposuretime = 0;
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    double exposure = 0;
                    status       = MVSDK.MvApi.CameraGetExposureTime(_deviceRef, ref exposure);
                    exposuretime = (float)exposure;

                    rt = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置曝光时间失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置曝光时间失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #10
0
        public override bool GetGain(out float gain)
        {
            gain = 0;
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    int g = Convert.ToInt32(gain);
                    status = MVSDK.MvApi.CameraGetAnalogGain(_deviceRef, ref g);
                    gain   = g;

                    rt = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置模拟增益失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置增益失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #11
0
        /// <summary>
        /// 设置消抖时间
        /// </summary>
        /// <param name="idx">端口索引</param>
        /// <param name="debouncertime">消抖时间,单位微秒</param>
        /// <returns></returns>
        protected override bool DoSetDebouncerTime(int lineIdx, float debouncertime)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    //SDK消抖时间单位为微秒,转换成微秒
                    uint debouncerT = Convert.ToUInt32(debouncertime);
                    status = MVSDK.MvApi.CameraSetExtTrigJitterTime(_deviceRef, debouncerT);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置防抖时间失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置防抖时间失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #12
0
        /// <summary>
        /// 设置触发延时
        /// </summary>
        /// <param name="trigdelay">延时时间,单位毫秒</param>
        /// <returns></returns>
        protected override bool DoSetTriggerDelay(int lineIdx, float trigdelay)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    //SDK触发延时单位为微秒,转换成微秒
                    uint delay = Convert.ToUInt32(trigdelay) * 1000;
                    status = MVSDK.MvApi.CameraSetTriggerDelayTime(_deviceRef, delay);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置触发延迟失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置触发延迟失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #13
0
        public override bool DoRegisterImageGrabbedCallBack()
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                MVSDK.pfnCameraGrabberFrameCallback del = _SDKImageGrabbedDel;

                if (del != null && _deviceRef > 0)
                {
                    status = MVSDK.MvApi.CameraGrabber_SetRGBCallback(_grabber, del, IntPtr.Zero);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机注册图像采集回调失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机注册采集回调函数失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #14
0
        private bool CreateCameraSetPage(System.Int32 devieRef, System.IntPtr windowHandle, string promption)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    //SDK根据相机相机型号动态创建相机的配置窗口
                    status = MVSDK.MvApi.CameraCreateSettingPage(devieRef, windowHandle, promption, /*设置页面信息回调*/ null, /*设置页面上下文回调*/ (System.IntPtr)null, 0);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机创建设置窗口失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机创建设置窗口失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch (Exception ex)
            {
                if (DriverExceptionDel != null)
                {
                    DriverExceptionDel(string.Format("错误:迈德威视相机创建设置窗口失败!\n错误描述:{0}", ex.Message));
                }
            }
            return(rt);
        }
Пример #15
0
        public override bool DoShowCameraSetPage()
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    //显示相机设置窗口
                    status = MVSDK.MvApi.CameraShowSettingPage(_deviceRef, 1);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机显示设置窗口失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机显示设置窗口失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch (Exception ex)
            {
                if (DriverExceptionDel != null)
                {
                    DriverExceptionDel(string.Format("错误:迈德威视相机显示设置窗口失败!\n错误描述:{0}", ex.Message));
                }
            }
            return(rt);
        }
Пример #16
0
        public override bool DoSetFrameRate(float fps)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    status = MVSDK.MvApi.CameraSetFrameSpeed(_deviceRef, (int)fps);   //帧率参数
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置采集帧率失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置采集帧率失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #17
0
        protected override bool DoStartGrab()
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    status = MVSDK.MvApi.CameraGrabber_StartLive(_grabber);
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机开启采集失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置开启采集失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #18
0
        public override bool DoSoftTriggerOnce()
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    status = MVSDK.MvApi.CameraSoftTriggerEx(_deviceRef, 1);//执行软触发时,会清空相机内部缓存,重新开始曝光取一张图像
                    rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机软触发采集失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机单次软触发采集失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #19
0
        /// <summary>
        /// 方法:设置采集模式
        /// </summary>
        /// <param name="acqmode"></param>
        /// <param name="frameNum"></param>
        /// <returns></returns>
        public override bool DoSetAcquisitionMode(ProCommon.Communal.AcquisitionMode acqmode, uint frameNum)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    switch (acqmode)
                    {
                    case ProCommon.Communal.AcquisitionMode.Continue:
                        status = MVSDK.MvApi.CameraSetTriggerMode(_deviceRef, 0);    //官方驱动:0表示连续模式,1是软触发,2是硬触发
                        break;

                    case ProCommon.Communal.AcquisitionMode.SoftTrigger:
                        status = MVSDK.MvApi.CameraSetTriggerMode(_deviceRef, 1);    //官方驱动:0表示连续模式,1是软触发,2是硬触发
                        rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                        if (rt)
                        {
                            status = MVSDK.MvApi.CameraSetTriggerCount(_deviceRef, (int)frameNum);
                        }
                        break;

                    case ProCommon.Communal.AcquisitionMode.ExternalTrigger:
                        status = MVSDK.MvApi.CameraSetTriggerMode(_deviceRef, 2);    //官方驱动:0表示连续模式,1是软触发,2是硬触发
                        rt     = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                        if (rt)
                        {
                            status = MVSDK.MvApi.CameraSetTriggerCount(_deviceRef, (int)frameNum);
                        }
                        break;

                    default: break;
                    }
                    rt = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置采集模式失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置设备采集模式失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Пример #20
0
        public override bool DoOpen()
        {
            bool rt = false;

#pragma warning disable CS0219 // The variable 'status' is assigned but its value is never used
            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
#pragma warning restore CS0219 // The variable 'status' is assigned but its value is never used
            try
            {
                if (_deviceRef > 0)
                {
                    //获取相机的特性描述
                    MVSDK.MvApi.CameraGetCapability(_deviceRef, out _deviceCapacity);
                    if (_deviceCapacity.sIspCapacity.bMonoSensor != 0)
                    {
                        //黑白相机输出8位灰度图数据
                        MVSDK.MvApi.CameraSetIspOutFormat(_deviceRef, (uint)MVSDK.emImageFormat.CAMERA_MEDIA_TYPE_MONO8);
                    }

                    /* 可以不需要
                     *
                     * //设置抓拍通道的分辨率
                     * MVSDK.tSdkImageResolution tResolution;
                     * tResolution.uSkipMode = 0;
                     * tResolution.uBinAverageMode = 0;
                     * tResolution.uBinSumMode = 0;
                     * tResolution.uResampleMask = 0;
                     * tResolution.iVOffsetFOV = 0;
                     * tResolution.iHOffsetFOV = 0;
                     * tResolution.iWidthFOV = Capacity.sResolutionRange.iWidthMax;
                     * tResolution.iHeightFOV = Capacity.sResolutionRange.iHeightMax;
                     * tResolution.iWidth = tResolution.iWidthFOV;
                     * tResolution.iHeight = tResolution.iHeightFOV;
                     * //tResolution.iIndex = 0xff;表示自定义分辨率,如果tResolution.iWidth和tResolution.iHeight
                     * //定义为0,则表示跟随预览通道的分辨率进行抓拍。抓拍通道的分辨率可以动态更改。
                     * //本例中将抓拍分辨率固定为最大分辨率。
                     * tResolution.iIndex = 0xff;
                     * tResolution.acDescription = new byte[32];//描述信息可以不设置
                     * tResolution.iWidthZoomHd = 0;
                     * tResolution.iHeightZoomHd = 0;
                     * tResolution.iWidthZoomSw = 0;
                     * tResolution.iHeightZoomSw = 0;
                     * MVSDK.MvApi.CameraSetResolutionForSnap(_deviceRef, ref tResolution);
                     *
                     */
                    rt = true;
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机打开失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }