public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { var cameraGuids = new List <Guid>(); var cameraCount = CLEye.CLEyeGetCameraCount(); for (int i = 0; i < cameraCount; i++) { cameraGuids.Add(CLEye.CLEyeGetCameraUUID(i)); } return(new StandardValuesCollection(cameraGuids)); }
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."); } }
public CLEyeSource() { ColorMode = CLEyeCameraColorMode.CLEYE_COLOR_RAW; Resolution = CLEyeCameraResolution.CLEYE_VGA; FrameRate = 60; AutoWhiteBalance = true; Exposure = 511; source = Observable.Create <IplImage>((observer, cancellationToken) => { return(Task.Factory.StartNew(() => { lock (captureLock) { Load(); try { while (!cancellationToken.IsCancellationRequested) { if (CLEye.CLEyeCameraGetFrame(camera, image.ImageData, 500)) { if (image.Channels == 4) { CV.CvtColor(image, output, ColorConversion.Bgra2Bgr); } observer.OnNext(output.Clone()); } } } finally { Unload(); } } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default)); }) .PublishReconnectable() .RefCount(); }
private void Unload() { CLEye.CLEyeCameraStop(camera); CLEye.CLEyeDestroyCamera(camera); camera = IntPtr.Zero; }