Ejemplo n.º 1
0
 public MvaU3BoardCam()
 {
     m_Camera = new uEye.Camera();
     m_Camera.Init();
     m_Camera.Memory.Allocate();
     m_Camera.Acquisition.Capture(uEye.Defines.DeviceParameter.DontWait);
 }
Ejemplo n.º 2
0
        private void InitCamera()
        {
            Camera = new uEye.Camera();
            uEye.Defines.Status statusRet = 0;
            statusRet = Camera.Init();
            if (statusRet != uEye.Defines.Status.Success)
            {
                MessageBox.Show("Camera initializing failed");
                Environment.Exit(-1);
            }

            //   Camera.Parameter.Load();

            Camera.Trigger.Set(uEye.Defines.TriggerMode.Software);

            statusRet = Camera.Focus.Auto.SetEnable(true);
            if (statusRet == uEye.Defines.Status.Success)
            {
                showLog("自动对焦成功");
            }
            uEye.Types.ImageFormatInfo[] list;
            Camera.Size.ImageFormat.GetList(out list);
            Camera.PixelFormat.Set(uEye.Defines.ColorMode.BGR8Packed);
            uint formatId = (uint)list[0].FormatID;

            Camera.Size.ImageFormat.Set(formatId);
            statusRet = Camera.Memory.Allocate();

            //   Camera.Focus.Zone.SetAOI(new Rectangle(new Point(1100, 636), new Size(672, 596)));
            if (statusRet != uEye.Defines.Status.Success)
            {
                MessageBox.Show("Allocate Memory failed");
                Environment.Exit(-1);
            }

            Camera.EventFrame += onFrameEvent;
            Camera.EventAutoBrightnessFinished += onAutoShutterFinished;
            Camera.AutoFeatures.Software.WhiteBalance.Enabled = false;
            //Camera.Timing.Expoure.Set(80);
            Camera.Focus.Auto.Enabled = true;

            Camera.AutoFeatures.Software.Gain.Enabled = false;
            statusRet = Camera.AutoFeatures.Sensor.GainShutter.SetEnable(false);
            if (statusRet != uEye.Defines.Status.Success)
            {
                MessageBox.Show("自动曝光设置关闭失败");
                Environment.Exit(-1);
            }

            statusRet = Camera.Timing.Exposure.Set(32);

            if (statusRet != uEye.Defines.Status.Success)
            {
                MessageBox.Show("曝光设置失败");
                Environment.Exit(-1);
            }

            //   CB_Auto_Gain_Balance.Enabled = Camera.AutoFeatures.Software.Gain.Supported;
            //  CB_Auto_White_Balance.Enabled = Camera.AutoFeatures.Software.WhiteBalance.Supported;
        }
Ejemplo n.º 3
0
 public void ConnectIDS(int DeviceID, string iniPath)
 {
     //初始化相機
     nRet = m_Camera.Init(DeviceID);
     Thread.Sleep(200);
     LoadiniFile(iniPath);
     Thread.Sleep(200);
     //分配相機記憶體
     nRet = m_Camera.Memory.Allocate();
     //相機Frame更新時觸發
     m_Camera.EventFrame += onFrameEvent;
 }
        private void InitCamera()
        {
            idsCamera = new uEye.Camera();

            uEye.Defines.Status statusRet = 0;

            // Open Camera
            statusRet = idsCamera.Init();
            if (statusRet != uEye.Defines.Status.Success)
            {
                MessageBox.Show("Camera initializing failed");
                Environment.Exit(-1);
            }

            // Allocate Memory
            statusRet = idsCamera.Memory.Allocate();
            if (statusRet != uEye.Defines.Status.Success)
            {
                MessageBox.Show("Allocate Memory failed");
                Environment.Exit(-1);
            }

            // Start Live Video
            statusRet = idsCamera.Acquisition.Capture();
            if (statusRet != uEye.Defines.Status.Success)
            {
                MessageBox.Show("Start Live Video failed");
            }
            else
            {
                bLive = true;
            }

            // Connect Event
            idsCamera.EventFrame += onFrameEvent;
            idsCamera.EventAutoBrightnessFinished += onAutoShutterFinished;

            //   CB_Auto_Gain_Balance.Enabled = idsCamera.AutoFeatures.Software.Gain.Supported;
            //   CB_Auto_White_Balance.Enabled = idsCamera.AutoFeatures.Software.WhiteBalance.Supported;
        }
        public void Open()
        {
            if (Camera.IsOpened)
            {
                return;
            }

            uEye.Defines.Status statusRet = 0;

            // Open Camera
            statusRet = Camera.Init(cameraIdx);
            if (statusRet != uEye.Defines.Status.Success)
            {
                throw new Exception("Camera initializing failed");
            }
            uEye.Types.SensorInfo info = new uEye.Types.SensorInfo();
            Camera.Information.GetSensorInfo(out info);

            Camera.Parameter.Load();

            statusRet = Camera.Memory.Allocate();
            if (statusRet != uEye.Defines.Status.Success)
            {
                throw new Exception("Allocate Memory failed");
            }
            Camera.Trigger.Set(uEye.Defines.TriggerMode.Continuous);
            Camera.EventFrame += onFrameEvent;
            try
            {
                Camera.Device.Feature.ShutterMode.Set(uEye.Defines.Shuttermode.Global);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 6
0
        private void onFormLoad(object sender, EventArgs e)
        {
            // load form in the background
            this.WindowState = FormWindowState.Minimized;

            // Store a reference to every textbox in the form
            textBoxes.Add(tbBlueMin);
            textBoxes.Add(tbGreenMin);
            textBoxes.Add(tbRedMin);
            textBoxes.Add(tbBlueMax);
            textBoxes.Add(tbGreenMax);
            textBoxes.Add(tbRedMax);

            // Create camera object
            __uEyeCamera = new uEye.Camera();

            uEye.Defines.Status statusRet = 0;

            // Open __ueyeCamera
            statusRet = __uEyeCamera.Init();
            if (statusRet != uEye.Defines.Status.Success)
            {
                label1.Text = "__ueyeCamera initializing failed";
                Environment.Exit(-1);
            }

            // Set Color Format
            uEye.Types.SensorInfo SensorInfo;
            statusRet = __uEyeCamera.Information.GetSensorInfo(out SensorInfo);

            if (SensorInfo.SensorColorMode == uEye.Defines.SensorColorMode.Bayer)
            {
                statusRet = __uEyeCamera.PixelFormat.Set(uEye.Defines.ColorMode.BGR8Packed);
            }
            else
            {
                statusRet = __uEyeCamera.PixelFormat.Set(uEye.Defines.ColorMode.Mono8);
            }


            // Allocate Memory
            statusRet = __uEyeCamera.Memory.Allocate();
            if (statusRet != uEye.Defines.Status.Success)
            {
                label1.Text = "Allocate Memory failed";
                Environment.Exit(-1);
            }

            // Start Live Video
            statusRet = __uEyeCamera.Acquisition.Capture();
            if (statusRet != uEye.Defines.Status.Success)
            {
                label1.Text = "Start Live Video failed";
            }


            // Get last image memory
            __uEyeCamera.AutoFeatures.Software.WhiteBalance.SetEnable(true);
            __uEyeCamera.AutoFeatures.Software.Shutter.SetEnable(true);
            __uEyeCamera.AutoFeatures.Software.Gain.SetEnable(true);
            Thread.Sleep(3000); // Wait if Gain is finished
            __uEyeCamera.Focus.Auto.SetEnable(true);

            // Connect Event
            __uEyeCamera.EventFrame += onFrameEvent;

            this.WindowState = FormWindowState.Maximized;
        }