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);
 }
        public UEyeCamera(int idx, string name, ViDi2.Training.UI.UEyeCameraProvider provider)
        {
            Camera    = new uEye.Camera();
            cameraIdx = idx;
            Provider  = provider;
            Name      = name;

            parameters = new ObservableCollection <ICameraParameter>
            {
                new CameraParameter("Grayscale", () => GrayScale, null),
                new CameraParameter("Sensor Size", () =>
                {
                    uEye.Types.SensorInfo info;
                    Camera.Information.GetSensorInfo(out info);
                    return(new System.Windows.Size(info.MaxSize.Width, info.MaxSize.Height));
                },
                                    null),
                new CameraParameter("Exposure Time", () => ExposureTime, (value) => ExposureTime     = (double)value),
                new CameraParameter("Auto Exposure", () => IsAutoExposure, (value) => IsAutoExposure = (bool)value),
                new CameraParameter("Frame Rate", () => FrameRate, (value) => FrameRate = (double)value),
                new CameraParameter("Binning", () => Binning, (value) => Binning        = (Point)value),
                new CameraParameter("Area of Interest", () => AreaOfInterest, (value) => AreaOfInterest = (Rect)value),
                new CameraParameter("Pixel Clock", () => PixelClock, (value) => PixelClock       = (int)value),
                new CameraParameter("Managed Image", () => ManagedImage, (value) => ManagedImage = (bool)value),
            };
        }
Ejemplo n.º 3
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;
        }
        private void onFrameEvent(object sender, EventArgs e)
        {
            uEye.Camera Camera = sender as uEye.Camera;

            Int32 s32MemID;

            Camera.Memory.GetActive(out s32MemID);

            Camera.Display.Render(s32MemID, displayHandle, uEye.Defines.DisplayRenderMode.FitToWindow);
        }
Ejemplo n.º 5
0
        private void onFrameEvent(object sender, EventArgs e)
        {
            uEye.Camera Camera = sender as uEye.Camera;

            Int32 s32MemID;

            uEye.Defines.Status statusRet = Camera.Memory.GetLast(out s32MemID);

            if ((uEye.Defines.Status.SUCCESS == statusRet) && (0 < s32MemID))
            {
                if (uEye.Defines.Status.SUCCESS == Camera.Memory.Lock(s32MemID))
                {
                    Camera.Display.Render(s32MemID, m_displayHandle, uEye.Defines.DisplayRenderMode.FitToWindow);
                    Camera.Memory.Unlock(s32MemID);
                }
            }
        }
Ejemplo n.º 6
0
 public IDS(int DeviceID)
 {
     m_Camera = new Camera();
     //if (Form1.ARGS.Length != 0)
     //{
     //    if (string.IsNullOrEmpty(Form1.ARGS[0])) ConnectIDS(DeviceID, "IDS.ini");
     //    else ConnectIDS(DeviceID, Form1.ARGS[0]);
     //}
     //else
     //{
     //    ConnectIDS(DeviceID, "IDS.ini");
     //}
     ConnectIDS(DeviceID, "IDS.ini");
     uEye.Defines.Status statusRet;
     //取得相機Size
     statusRet = m_Camera.Size.AOI.Get(out imageRect);
 }
        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;
        }
Ejemplo n.º 8
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;
        }