public override void SetExtTrigger()
        {
            try
            {
                CameraSdkStatus st = MvApi.CameraSetExtTrigSignalType(m_hCamera, 1);//下降沿触发
                st = MvApi.CameraSetTriggerMode(m_hCamera, (int)emSdkSnapMode.EXTERNAL_TRIGGER);


                st = MvApi.CameraSetTriggerDelayTime(m_hCamera, (uint)triggerDelayAbs);

                //m_pOperator.SetEnumValue("ExposureAuto", 0);

                //m_pOperator.SetFloatValue("TriggerDelay", (float)triggerDelayAbs);

                st = MvApi.CameraSetExtTrigJitterTime(m_hCamera, (uint)LineDebouncerTimeAbs);
                //m_pOperator.SetIntValue("LineDebouncerTime", (uint)LineDebouncerTimeAbs);
                Command      = Command.ExtTrigger;
                IsExtTrigger = true;
            }
            catch (Exception ex)
            {
                Util.WriteLog(this.GetType(), ex);
                Util.Notify("相机外触发设置异常");
            }
        }
Beispiel #2
0
        public bool InitCamera()
        {
            const int MAX_CAMS = 2;

            tSdkCameraDevInfo[] sCameraList = null;
            int iCameraNums = MAX_CAMS;
            tSdkCameraCapbility sCameraInfo = new tSdkCameraCapbility();

            CameraSdkStatus status = MvApi.CameraEnumerateDevice(out sCameraList);

            if (status != CameraSdkStatus.CAMERA_STATUS_SUCCESS || iCameraNums == 0)
            {
                return(false);
            }

            //只假设连接了一个相机。
            if ((status = MvApi.CameraInit(ref sCameraList[0], -1, -1, ref m_hCamera)) != CameraSdkStatus.CAMERA_STATUS_SUCCESS)
            {
                string msg = string.Format("***Failed to init the camera! Error code is {0}", status);
                WinCall.TraceMessage(msg);
                return(false);
            }

            //Get properties description for this camera.
            MvApi.CameraGetCapability(m_hCamera, out sCameraInfo);
            m_ImageBufferSnapshot = Marshal.AllocHGlobal(sCameraInfo.sResolutionRange.iWidthMax * sCameraInfo.sResolutionRange.iHeightMax * 3 + 1024);
            return(true);
        }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //1打开窗口、赋值线程状态
            //2枚举设备
            //3.初始化设备
            //3.申请内存  获取特性 获取位数
            //4.设置触发模式
            //5.开启绑定线程
            //6开始采集
            //6开始采集(默认连续,不设置采集模式的话)
            Control.CheckForIllegalCrossThreadCalls = false;
            HOperatorSet.OpenWindow(0, 0, pictureBox1.Width, pictureBox1.Height, pictureBox1.Handle, "", "", out hv_WindowHandle);
            HDevWindowStack.Push(hv_WindowHandle);
            status = MvApi.CameraEnumerateDevice(out tCameraDevInfoList);
            //枚举设备
            if (tCameraDevInfoList != null)//此时iCameraCounts返回了实际连接的相机个数。如果大于1,则初始化第一个相机
            {
                status = MvApi.CameraInit(ref tCameraDevInfoList[0], -1, -1, ref m_hCamera);
                //初始化第一个相机

                //获得相机特性描述
                MvApi.CameraGetCapability(m_hCamera, out tCameraCapability);

                //申请内存
                m_ImageBuffer = Marshal.AllocHGlobal(tCameraCapability.sResolutionRange.iWidthMax * tCameraCapability.sResolutionRange.iHeightMax * 3 + 1024);
                //MvApi.CameraSetTriggerMode(m_hCamera, 0);
                m_bExitCaptureThread = false;
                m_tCaptureThread     = new Thread(new ThreadStart(CaptureThreadProc));
                m_tCaptureThread.Start();
                MvApi.CameraPlay(m_hCamera);
            }
        }
 public override void ContinuousShotStop()
 {
     try
     {
         // Set an enum parameter.
         if (m_Grabber == IntPtr.Zero)
         {
             return;
         }
         CameraSdkStatus status;
         CameraSdkStatus st = MvApi.CameraSetExtTrigSignalType(m_hCamera, 1);//上升沿触发
         status           = MvApi.CameraSetTriggerMode(m_hCamera, (int)emSdkSnapMode.SOFT_TRIGGER);
         IsContinuousShot = false;
         IsExtTrigger     = false;
         Task.Run(() =>
         {
             ignoreImage = true;
             Thread.Sleep(1000);
             ignoreImage = false;
         });
     }
     catch (Exception ex)
     {
         Util.WriteLog(this.GetType(), ex);
         Util.Notify("相机连续采集停止异常");
     }
 }
Beispiel #5
0
        private void checkOnlineTimer_Tick(object sender, EventArgs e)
        {
            HTuple          newHandle = hv_AcqHandle.H.TupleIsValidHandle();
            CameraSdkStatus status    = MvApi.CameraConnectTest(newHandle);

            if (status != 0)
            {
                HOperatorSet.SetFramegrabberParam(hv_AcqHandle, "trigger_mode", 1);
                camStatus.Text      = "相机已掉线 正在重连中...";
                camStatus.ForeColor = Color.Red;
                button2.Text        = "开启";
                modelList.Enabled   = true;
                btnAddModel.Enabled = false;
                button2.Enabled     = false;
                MvApi.CameraReConnect(newHandle);
            }
            else
            {
                camStatus.Text      = "上线";
                camStatus.ForeColor = Color.Green;
                button2.Enabled     = true;
                if (button2.Text == "开启")
                {
                    btnAddModel.Enabled = true;
                }
            }
        }
Beispiel #6
0
        private void CameraGrabberSaveImageComplete2(
            IntPtr Grabber,
            IntPtr Image,       // 需要调用CameraImage_Destroy释放
            CameraSdkStatus Status,
            IntPtr Context)
        {
            if (Image != IntPtr.Zero)
            {
                tSdkCameraDevInfo devInfo;
                MvApi.CameraGrabber_GetCameraDevInfo(Grabber, out devInfo);

                Encoding myEncoding = Encoding.GetEncoding("utf-8");
                string   sData      = myEncoding.GetString(devInfo.acSn);
                sData = sData.TrimEnd('\0');
                sData = sData.Substring(0, 12);

                string filename = System.IO.Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory.ToString(),
                    string.Format("{0}-{1}-{2}.jpg", System.Environment.TickCount, sData, devInfo.uInstance));

                MvApi.CameraImage_SaveAsJpeg(Image, filename, 90);

                m_saveFilenames += filename + "\r\n";
                m_countFiles++;
            }
            if (m_countFiles == CAMERA_NUM)
            {
                MessageBox.Show(m_saveFilenames);
            }


            MvApi.CameraImage_Destroy(Image);
        }
        private void InitCamera()
        {
            CameraSdkStatus status = 0;

            tSdkCameraDevInfo[] DevList;
            MvApi.CameraEnumerateDevice(out DevList);
            int NumDev = (DevList != null ? DevList.Length : 0);

            if (NumDev < 1)
            {
                MessageBox.Show("未扫描到相机");
                return;
            }
            else if (NumDev == 1)
            {
                status = MvApi.CameraGrabber_Create(out m_Grabber, ref DevList[0]);
            }
            else
            {
                status = MvApi.CameraGrabber_CreateFromDevicePage(out m_Grabber);
            }

            if (status == 0)
            {
                MvApi.CameraGrabber_GetCameraDevInfo(m_Grabber, out m_DevInfo);
                MvApi.CameraGrabber_GetCameraHandle(m_Grabber, out m_hCamera);
                MvApi.CameraCreateSettingPage(m_hCamera, this.Handle, m_DevInfo.acFriendlyName, null, (IntPtr)0, 0);

                MvApi.CameraGrabber_SetRGBCallback(m_Grabber, m_FrameCallback, IntPtr.Zero);

                // 黑白相机设置ISP输出灰度图像
                // 彩色相机ISP默认会输出BGR24图像
                tSdkCameraCapbility cap;
                MvApi.CameraGetCapability(m_hCamera, out cap);
                if (cap.sIspCapacity.bMonoSensor != 0)
                {
                    MvApi.CameraSetIspOutFormat(m_hCamera, (uint)MVSDK.emImageFormat.CAMERA_MEDIA_TYPE_MONO8);

                    // 创建灰度调色板
                    Bitmap Image = new Bitmap(1, 1, PixelFormat.Format8bppIndexed);
                    m_GrayPal = Image.Palette;
                    for (int Y = 0; Y < m_GrayPal.Entries.Length; Y++)
                    {
                        m_GrayPal.Entries[Y] = Color.FromArgb(255, Y, Y, Y);
                    }
                }

                // 设置VFlip,由于SDK输出的数据默认是从底到顶的,打开VFlip后就可以直接转换为Bitmap
                MvApi.CameraSetMirror(m_hCamera, 1, 1);

                // 为了演示如何在回调中使用相机数据创建Bitmap并显示到PictureBox中,这里不使用SDK内置的绘制操作
                //MvApi.CameraGrabber_SetHWnd(m_Grabber, this.DispWnd.Handle);

                MvApi.CameraGrabber_StartLive(m_Grabber);
            }
            else
            {
                MessageBox.Show(String.Format("打开相机失败,原因:{0}", status));
            }
        }
Beispiel #8
0
        private void InitCamera()
        {
            CameraSdkStatus status = 0;

            tSdkCameraDevInfo[] DevList;
            MvApi.CameraEnumerateDevice(out DevList);
            int NumDev = (DevList != null ? DevList.Length : 0);

            if (NumDev < 1)
            {
                MessageBox.Show("未扫描到相机");
                return;
            }
            else if (NumDev == 1)
            {
                status = MvApi.CameraGrabber_Create(out m_Grabber, ref DevList[0]);
            }
            else //选择哪个相机
            {
                status = MvApi.CameraGrabber_CreateFromDevicePage(out m_Grabber);
            }

            if (status == 0)
            {
                //获得相机的描述信息
                MvApi.CameraGrabber_GetCameraDevInfo(m_Grabber, out m_DevInfo);
                //获得相机的句柄
                MvApi.CameraGrabber_GetCameraHandle(m_Grabber, out m_hCamera);
                //sheshe设置相机配置窗口的启动页面
                MvApi.CameraCreateSettingPage(m_hCamera, this.Handle, m_DevInfo.acFriendlyName, null, (IntPtr)0, 0);
                //设置RGB回调函数
                MvApi.CameraGrabber_SetRGBCallback(m_Grabber, m_FrameCallback, IntPtr.Zero);
                tSdkCameraCapbility cap;
                //黑白相机设置ISP输出灰度图像
                //彩色相机ISP默认输出BGR24图像

                //获得相机特性
                MvApi.CameraGetCapability(m_hCamera, out cap);
                //表示该型号相机是否为黑白相机,如果是黑白相机,则颜色相关的功能都无法调节
                if (cap.sIspCapacity.bMonoSensor != 0)
                {
                    MvApi.CameraSetIspOutFormat(m_hCamera, (uint)MVSDK.emImageFormat.CAMERA_MEDIA_TYPE_MONO8);
                    //创建灰度调色板
                    Bitmap Image = new Bitmap(1, 1, PixelFormat.Format8bppIndexed);
                    m_GrayPal = Image.Palette;
                    for (int Y = 0; Y < m_GrayPal.Entries.Length; Y++)
                    {
                        m_GrayPal.Entries[Y] = Color.FromArgb(255, Y, Y, Y);
                    }
                }
                //设置vflip,由于sdk输出的数据默认是从底部到顶部,打开flip后就可以直接转成bitmap
                MvApi.CameraSetMirror(m_hCamera, 1, 1);
                // MvApi.CameraGrabber_StartLive(m_Grabber);
            }
            else
            {
                MessageBox.Show(String.Format("打开相机失败,原因:{0}", status));
            }
        }
        private void buttonBeginRecord_Click(object sender, EventArgs e)
        {
            if (m_Grabber == IntPtr.Zero)
            {
                return;
            }

            if (m_bRecording)
            {
                m_bRecording = false;

                if (MvApi.CameraStopRecord(m_hCamera) == 0)
                {
                    MessageBox.Show("录像保存成功");
                }
                else
                {
                    MessageBox.Show("录像保存失败");
                }

                this.buttonBeginRecord.Text = "开始录像";
                this.Text = "录像";
            }
            else
            {
                String SavePath = this.textBoxRecordPath.Text;
                if (SavePath.Length < 1)
                {
                    MessageBox.Show("请先选择录像文件的保存路径");
                    return;
                }

                // 压缩格式3:需要安装DivX编码器
                CameraSdkStatus status     = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
                int[]           FormatList = new int[] { 3, 0 };
                foreach (int Fmt in FormatList)
                {
                    status = MvApi.CameraInitRecord(m_hCamera, Fmt, SavePath, 0, 100, 30);
                    if (status == 0)
                    {
                        break;
                    }
                }
                if (status != 0)
                {
                    MessageBox.Show("启动录像失败");
                    return;
                }

                m_bRecording = true;
                this.buttonBeginRecord.Text = "停止录像";
                this.Text = "录像(录像中。。。)";
            }
        }
Beispiel #10
0
        private CameraSdkStatus buttonBeginRecord_InitACameraRecord(CameraHandle m_hCamera, string SavePath)
        {
            CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;

            int[] FormatList = new int[] { 3, 1, 0 };
            foreach (int Fmt in FormatList)
            {
                status = MvApi.CameraInitRecord(m_hCamera, Fmt, SavePath, 0, 100, 30);
                if (status == 0)
                {
                    break;
                }
            }
            return(status);
        }
Beispiel #11
0
        private void buttonBeginRecord_Click(object sender, EventArgs e)
        {
            if (m_Grabber == IntPtr.Zero)
            {
                return;
            }

            if (m_bRecording)
            {
                m_bRecording = false;

                CameraSdkStatus status = MvApi.CameraStopRecord(m_hCamera);

                if (status == 0)
                {
                    MessageBox.Show("录像保存成功");
                }
                else
                {
                    MessageBox.Show("录像保存失败");
                }

                this.buttonBeginRecord.Text = "开始录像";
                this.Text = "录像";
            }
            else
            {
                String SavePath = this.textBoxRecordPath.Text;
                if (SavePath.Length < 1)
                {
                    MessageBox.Show("请先选择录像文件的保存路径");
                    return;
                }

                // 压缩格式3:需要安装DivX编码器
                CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
                status = buttonBeginRecord_InitACameraRecord(m_hCamera, SavePath);
                if (status != 0)
                {
                    MessageBox.Show("启动录像失败");
                    return;
                }

                m_bRecording = true;
                this.buttonBeginRecord.Text = "停止录像";
                this.Text = "录像(录像中。。。)";
            }
        }
        private void CameraGrabberSaveImageComplete(
            IntPtr Grabber,
            IntPtr Image,       // 需要调用CameraImage_Destroy释放
            CameraSdkStatus Status,
            IntPtr Context)
        {
            if (Image != IntPtr.Zero)
            {
                string filename = System.IO.Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory.ToString(),
                    string.Format("{0}.bmp", System.Environment.TickCount));

                MvApi.CameraImage_SaveAsBmp(Image, filename);

                MessageBox.Show(filename);
            }

            MvApi.CameraImage_Destroy(Image);
        }
Beispiel #13
0
 public override void ContinuousShot()
 {
     if (m_Grabber == IntPtr.Zero)
     {
         return;
     }
     try
     {
         Command = Command.Video;
         MvApi.CameraSetTriggerMode(m_hCamera, (int)emSdkSnapMode.CONTINUATION);
         CameraSdkStatus suatus = MvApi.CameraGrabber_StartLive(m_Grabber);
         if (suatus != CameraSdkStatus.CAMERA_STATUS_SUCCESS)
         {
             Util.Notify("相机连续采集开始异常");
         }
         IsContinuousShot = true;
     }
     catch (Exception ex)
     {
         Util.WriteLog(this.GetType(), ex);
         Util.Notify("相机连续采集开始异常");
     }
 }
Beispiel #14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //1打开窗口
            //2枚举设备
            //3初始化设备
            //4.获得位数,申请内存
            //5绑定回调事件  并在回调事件中加入halcon显示代码
            //6开始采集(默认连续,不设置采集模式的话)
            HOperatorSet.OpenWindow(0, 0, pictureBox1.Width, pictureBox1.Height, pictureBox1.Handle, "", "", out hv_WindowHandle);
            HDevWindowStack.Push(hv_WindowHandle);
            status = MvApi.CameraEnumerateDevice(out tCameraDevInfoList);
            if (tCameraDevInfoList != null)//此时iCameraCounts返回了实际连接的相机个数。如果大于1,则初始化第一个相机
            {
                status = MvApi.CameraInit(ref tCameraDevInfoList[0], -1, -1, ref m_hCamera);
            }
            MvApi.CameraGetCapability(m_hCamera, out tCameraCapability);

            m_ImageBuffer = Marshal.AllocHGlobal(tCameraCapability.sResolutionRange.iWidthMax * tCameraCapability.sResolutionRange.iHeightMax * 3 + 1024);

            m_CaptureCallback = new CAMERA_SNAP_PROC(ImageCaptureCallback);
            MvApi.CameraSetCallbackFunction(m_hCamera, m_CaptureCallback, m_iCaptureCallbackCtx, ref pCaptureCallOld);
            MvApi.CameraPlay(m_hCamera);
        }
Beispiel #15
0
        private void buttonBeginRecord_Click(object sender, EventArgs e)
        {
            //int CAMERA_NUM = 2;

            if (m_Grabber == null)
            {
                return;
            }
            for (int i = 0; i < CAMERA_NUM; i++)
            {
                if (m_Grabber[i] == IntPtr.Zero)
                {
                    return;
                }
            }


            if (m_bRecording)
            {
                m_bRecording = false;

                CameraSdkStatus status = 0;
                for (int i = 0; i < CAMERA_NUM; i++)
                {
                    status |= MvApi.CameraStopRecord(m_hCamera[i]);
                }

                if (status == 0)
                {
                    MessageBox.Show("录像保存成功");
                }
                else
                {
                    MessageBox.Show("录像保存失败");
                }

                this.buttonBeginRecord.Text = "开始一键录制";
                this.Text = "录像";
            }
            else
            {
                string[] SavePaths = new string[CAMERA_NUM];
                for (int i = 0; i < CAMERA_NUM; i++)
                {
                    SavePaths[i] = buttonBeginRecord_GetPathName(m_Grabber[i]);
                }

                // 压缩格式3:需要安装DivX编码器
                CameraSdkStatus status = 0;
                for (int i = 0; i < CAMERA_NUM; i++)
                {
                    status |= buttonBeginRecord_InitACameraRecord(m_hCamera[i], SavePaths[i]);
                }

                if (status != 0)
                {
                    MessageBox.Show("启动录像失败");
                    return;
                }

                m_bRecording = true;
                this.buttonBeginRecord.Text = "停止一键录制";
                this.Text = "录像(录像中。。。)";
            }
        }
Beispiel #16
0
        public bool cameraopen()
        {
            return(false);

#if USE_CALL_BACK
            CAMERA_SNAP_PROC pCaptureCallOld = null;
#endif
            if (m_hCamera > 0)
            {
                return(true);
            }
            if ((tCameraDevInfoList != null) && (tCameraDevInfoList.Length > 0))
            {
                //已经初始化过,直接返回 true
                return(true);
            }
            status = MvApi.CameraEnumerateDevice(out tCameraDevInfoList);
            //hfgon = true;
            if (status == CameraSdkStatus.CAMERA_STATUS_SUCCESS)
            {
                //hfgon = true;
                if (tCameraDevInfoList != null)//此时iCameraCounts返回了实际连接的相机个数。如果大于1,则初始化第一个相机
                {
                    status = MvApi.CameraInit(ref tCameraDevInfoList[0], -1, -1, ref m_hCamera);
                    if (status == CameraSdkStatus.CAMERA_STATUS_SUCCESS)
                    {
                        //获得相机特性描述
                        MvApi.CameraGetCapability(m_hCamera, out tCameraCapability);

                        m_ImageBuffer         = Marshal.AllocHGlobal(tCameraCapability.sResolutionRange.iWidthMax * tCameraCapability.sResolutionRange.iHeightMax * 3 + 1024);
                        m_ImageBufferSnapshot = Marshal.AllocHGlobal(tCameraCapability.sResolutionRange.iWidthMax * tCameraCapability.sResolutionRange.iHeightMax * 3 + 1024);

                        if (tCameraCapability.sIspCapacity.bMonoSensor != 0)
                        {
                            // 黑白相机输出8位灰度数据
                            MvApi.CameraSetIspOutFormat(m_hCamera, (uint)MVSDK.emImageFormat.CAMERA_MEDIA_TYPE_MONO8);
                        }

                        //设置抓拍通道的分辨率。
                        tSdkImageResolution tResolution;
                        tResolution.uSkipMode       = 0;
                        tResolution.uBinAverageMode = 0;
                        tResolution.uBinSumMode     = 0;
                        tResolution.uResampleMask   = 0;
                        tResolution.iVOffsetFOV     = 0;
                        tResolution.iHOffsetFOV     = 0;
                        tResolution.iWidthFOV       = tCameraCapability.sResolutionRange.iWidthMax;
                        tResolution.iHeightFOV      = tCameraCapability.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;

                        MvApi.CameraSetResolutionForSnap(m_hCamera, ref tResolution);
                        //try { if (exposuretime > 0) MvApi.CameraSetExposureTime(m_hCamera, exposuretime);  } catch { }
                        //try { if (gain > 0) MvApi.CameraSetGain(m_hCamera, Convert.ToInt32(gain / 100), Convert.ToInt32(gain / 100), Convert.ToInt32(gain / 100)); } catch { }
                        //try { if (contrast > 0) MvApi.CameraSetContrast(m_hCamera, contrast); } catch { }
                        //try { if (gamma > 0) MvApi.CameraSetGamma(m_hCamera, Convert.ToInt32(gamma)); } catch { }

                        //两种方式来获得预览图像,设置回调函数或者使用定时器或者独立线程的方式,
                        //主动调用CameraGetImageBuffer接口来抓图。
                        //本例中仅演示了两种的方式,注意,两种方式也可以同时使用,但是在回调函数中,
                        //不要使用CameraGetImageBuffer,否则会造成死锁现象。
#if USE_CALL_BACK
                        m_CaptureCallback = new CAMERA_SNAP_PROC(ImageCaptureCallback);
                        MvApi.CameraSetCallbackFunction(m_hCamera, m_CaptureCallback, m_iCaptureCallbackCtx, ref pCaptureCallOld);
#else //如果需要采用多线程,使用下面的方式
                        m_bExitCaptureThread = false;
                        //m_tCaptureThread = new Thread(new ThreadStart(CaptureThreadProc));
                        //m_tCaptureThread.Start();
                        return(true);
#endif
                    }
                    else
                    {
                        m_hCamera = 0;
                        String errstr    = string.Format("相机初始化错误,错误码{0},错误原因是", status);
                        String errstring = MvApi.CameraGetErrorString(status);
                        // string str1
                        MessageBox.Show(errstr + errstring, "ERROR");
                        Environment.Exit(0);
                        return(false);
                    }
                }
            }
            else
            {
                MessageBox.Show("没有找到相机,如果已经接上相机,可能是权限不够,请尝试使用管理员权限运行程序。");
                Environment.Exit(0);
            }
            return(false);

            //InitCamera();
            //if (cname == "") return;


            //hfgon = false;
            //try
            //{
            //    hfg = new HFramegrabber();
            //    //open_framegrabber ('GigEVision', 0, 0, 0, 0, 0, 0, 'default', -1, 'default', -1, 'false', 'default', 'xiangji1', 0, -1, AcqHandle)
            //    hfg.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1, "default", -1, "false", "default", cname, 0, -1);

            //    Thread.Sleep(300);
            //    try
            //    {
            //        if (cname.IndexOf("MindVision") > -1)
            //        {
            //            HOperatorSet.SetFramegrabberParam(hfg, "AcquisitionMode", "SingleFrame");
            //            HOperatorSet.SetFramegrabberParam(hfg, "AcquisitionFrameRate", "Mid");
            //        }
            //        try { if (exposuretime > 0) hfg.SetFramegrabberParam("ExposureTime", exposuretime); } catch { }
            //        try { if (gain > 0) hfg.SetFramegrabberParam("Gain", gain / 100); } catch { }
            //        try { if (contrast > 0) hfg.SetFramegrabberParam("Contrast", contrast); } catch { }
            //        try { if (gamma > 0) hfg.SetFramegrabberParam("Gamma", gamma); } catch { }
            //    }
            //    catch { }

            //    hfg.GrabImageStart(-1);
            //    //#himg = hfg.GrabImageAsync(-1);
            //    //#string ctype = "";
            //    //#himg.GetImagePointer1(out ctype, out iw, out ih);

            //    hfgon = true;
            //}
            //catch
            //{
            //    //MessageBox.Show("相机未连接!");
            //}
        }