Пример #1
0
        private void Load()
        {
            var guid = CameraGuid;

            if (!guid.HasValue)
            {
                guid = CLEye.CLEyeGetCameraUUID(CameraIndex);
                if (guid == Guid.Empty)
                {
                    throw new InvalidOperationException("No camera found with the given index.");
                }
            }

            camera = CLEye.CLEyeCreateCamera(guid.Value, ColorMode, Resolution, FrameRate);
            if (camera == IntPtr.Zero)
            {
                throw new InvalidOperationException("No camera found with the given GUID.");
            }

            AutoGain          = autoGain;
            AutoExposure      = autoExposure;
            AutoWhiteBalance  = autoWhiteBalance;
            Gain              = gain;
            Exposure          = exposure;
            WhiteBalanceRed   = whiteBalanceRed;
            WhiteBalanceGreen = whiteBalanceGreen;
            WhiteBalanceBlue  = whiteBalanceBlue;

            int width, height;

            CLEye.CLEyeCameraGetFrameDimensions(camera, out width, out height);

            switch (ColorMode)
            {
            case CLEyeCameraColorMode.CLEYE_COLOR_RAW:
            case CLEyeCameraColorMode.CLEYE_COLOR_PROCESSED:
                image  = new IplImage(new Size(width, height), IplDepth.U8, 4);
                output = new IplImage(image.Size, IplDepth.U8, 3);
                break;

            case CLEyeCameraColorMode.CLEYE_MONO_RAW:
            case CLEyeCameraColorMode.CLEYE_MONO_PROCESSED:
                image  = new IplImage(new Size(width, height), IplDepth.U8, 1);
                output = image;
                break;
            }

            if (!CLEye.CLEyeCameraStart(camera))
            {
                throw new InvalidOperationException("Unable to start camera.");
            }
        }