/// <summary> /// Configure device and report frame format that will be used during streaming. /// This method must return a proper ImageDescriptor so we can pre-allocate buffers. /// </summary> public ImageDescriptor Prepare() { Open(); if (device == null || featureControl == null) { return(ImageDescriptor.Invalid); } firstOpen = false; resultingFramerate = (float)DahengHelper.GetResultingFramerate(device); width = (int)featureControl.GetIntFeature("Width").GetValue(); height = (int)featureControl.GetIntFeature("Height").GetValue(); isColor = DahengHelper.IsColor(featureControl); ImageFormat format = ImageFormat.RGB24; incomingBufferSize = ImageFormatHelper.ComputeBufferSize(width, height, format); incomingBuffer = new byte[incomingBufferSize]; int outgoingBufferSize = ImageFormatHelper.ComputeBufferSize(width, height, format); bool topDown = false; return(new ImageDescriptor(format, width, height, topDown, outgoingBufferSize)); }
public SnapshotRetriever(CameraSummary summary, IGXFactory igxFactory) { this.summary = summary; try { stopwatch.Start(); device = igxFactory.OpenDeviceBySN(summary.Identifier, GX_ACCESS_MODE.GX_ACCESS_EXCLUSIVE); log.DebugFormat("{0} opened in {1} ms.", summary.Alias, stopwatch.ElapsedMilliseconds); stopwatch.Stop(); featureControl = device.GetRemoteFeatureControl(); DahengHelper.AfterOpen(featureControl); width = (int)featureControl.GetIntFeature("Width").GetValue(); height = (int)featureControl.GetIntFeature("Height").GetValue(); isColor = DahengHelper.IsColor(featureControl); stream = device.OpenStream(0); } catch (Exception e) { LogError(e, "Failed to open device"); } }
public SnapshotRetriever(CameraSummary summary, IGXFactory igxFactory) { this.summary = summary; try { device = igxFactory.OpenDeviceBySN(summary.Identifier, GX_ACCESS_MODE.GX_ACCESS_EXCLUSIVE); featureControl = device.GetRemoteFeatureControl(); DahengHelper.AfterOpen(featureControl); width = (int)featureControl.GetIntFeature("Width").GetValue(); height = (int)featureControl.GetIntFeature("Height").GetValue(); isColor = DahengHelper.IsColor(featureControl); stream = device.OpenStream(0); } catch (Exception e) { LogError(e, "Failed to open device"); } }
private void Open() { if (device != null) { Close(); } bool open = false; try { device = igxFactory.OpenDeviceBySN(summary.Identifier, GX_ACCESS_MODE.GX_ACCESS_EXCLUSIVE); featureControl = device.GetRemoteFeatureControl(); DahengHelper.AfterOpen(featureControl); open = true; } catch { log.DebugFormat("Could not open Daheng device."); } if (!open) { return; } SpecificInfo specific = summary.Specific as SpecificInfo; if (specific == null) { return; } // Store the camera object into the specific info so that we can retrieve device informations from the configuration dialog. specific.Device = device; isColor = DahengHelper.IsColor(featureControl); if (firstOpen) { // Always default to RGB24 for color cameras and Y800 for mono cameras. // Raw mode will have to be switched explicitly everytime for now. currentStreamFormat = isColor ? DahengStreamFormat.RGB : DahengStreamFormat.Mono; // Grab current values. Dictionary <string, CameraProperty> cameraProperties = CameraPropertyManager.Read(device); specific.CameraProperties = cameraProperties; specific.StreamFormat = currentStreamFormat; } else { CameraPropertyManager.WriteCriticalProperties(device, specific.CameraProperties); if (specific.StreamFormat != currentStreamFormat) { currentStreamFormat = specific.StreamFormat; } } try { stream = device.OpenStream(0); } catch { log.Debug("Could not start Daheng device."); } }