Esempio n. 1
0
        //开始采集
        private void CarmeraStartGrab()
        {
            int nRet = m_pOperator.StartGrabbing();

            if (MyCamera.MV_OK != nRet)
            {
                MessageBox.Show("开始取流失败!");
                return;
            }
        }
Esempio n. 2
0
        //开始采集
        private void CarmeraStartGrab()
        {
            int nRet = m_pOperator.StartGrabbing();

            if (MyCamera.MV_OK != nRet)
            {
                MessageBox.Show("开始取流失败!");
                return;
            }

            //显示
            nRet = m_pOperator.Display(m_CameraPicBox.Handle);
            if (MyCamera.MV_OK != nRet)
            {
                MessageBox.Show("显示失败!");
            }
        }
Esempio n. 3
0
        public void CameraStartGrab(PictureBox pictureBox)
        {
            int nRet = m_CameraOperator.StartGrabbing();

            if (MyCamera.MV_OK != nRet)
            {
                MessageBox.Show("开始取流失败!");
                return;
            }

            //显示
            nRet = m_CameraOperator.Display(pictureBox.Handle);
            if (MyCamera.MV_OK != nRet)
            {
                MessageBox.Show("显示失败!");
            }
        }
Esempio n. 4
0
        public override bool Open()
        {
            try
            {
                int nRet;


                //Util.Notify("相机开始打开");

                uint pixelFormat = 0;
                nRet = m_pOperator.GetEnumValue("PixelFormat", ref pixelFormat);
                if (MyCamera.MV_OK != nRet)
                {
                    throw new Exception("图像格式获取错误");
                }
                MyCamera.MvGvspPixelType imgType = (MyCamera.MvGvspPixelType)pixelFormat;
                if (imgType == MyCamera.MvGvspPixelType.PixelType_Gvsp_YUV411_Packed ||
                    imgType == MyCamera.MvGvspPixelType.PixelType_Gvsp_YUV422_Packed ||
                    imgType == MyCamera.MvGvspPixelType.PixelType_Gvsp_YUV422_YUYV_Packed ||
                    imgType == MyCamera.MvGvspPixelType.PixelType_Gvsp_YUV444_Packed)
                {
                    int result = m_pOperator.SetEnumValue("PixelFormat", (uint)MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed);
                    if (MyCamera.MV_OK != result)
                    {
                        throw new Exception("图像格式设置错误");
                    }
                }

                ////设置采集连续模式
                //nRet = m_pOperator.SetEnumValue("AcquisitionMode", 2);
                //if (MyCamera.MV_OK != nRet)
                //{
                //    throw new Exception("采集模式设置失败");

                //}

                //nRet = m_pOperator.SetEnumValue("TriggerMode", 0);
                //if (MyCamera.MV_OK != nRet)
                //{
                //    throw new Exception("触发模式设置失败");

                //}
                ImageCallback = new MyCamera.cbOutputdelegate(SaveImage);
                nRet          = m_pOperator.RegisterImageCallBack(ImageCallback, IntPtr.Zero);
                if (MyCamera.MV_OK != nRet)
                {
                    throw new Exception("回调函数注册失败");
                }


                ContinuousShotStop();
                //开始采集
                nRet = m_pOperator.StartGrabbing();
                if (MyCamera.MV_OK != nRet)
                {
                    throw new Exception("开始采集失败");
                }



                // 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();

                GetCameraSettingData();

                IsLink = true;
            }
            catch (Exception ex)
            {
                Util.WriteLog(this.GetType(), ex);
                Util.Notify("相机打开出现异常:" + ex.Message);
                throw ex;
            }
            return(true);
        }