private void btn_save_Click(object sender, RoutedEventArgs e) { CameraProperty.EndEdit(); ServiceProvider.Settings.Save(); _cameraDevice.LoadProperties(); ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.CameraPropertyWnd_Hide); }
private void UpdateTemperatureValue() { Debug.Assert(m_camera != null, "Camera can not be null."); try { CameraProperty camProp = m_camera.GetProperty(PropertyType.Temperature); if (camProp != null && camProp.present) { double kelvins = camProp.valueA / 10.0; double celcius = kelvins - 273.15; double fahrenheit = ((celcius * 9.0) / 5.0) + 32.0; m_temperatureValue.Text = string.Format(" {0:0.##}K / {1:0.##}°C / {2:0.##}°F", kelvins, celcius, fahrenheit); } else { m_temperatureValue.Text = "Not available"; } } catch (FC2Exception ex) { if (ex.Type == ErrorType.PropertyNotPresent) { m_temperatureValue.Text = "Not available"; } else { m_temperatureValue.Text = "N/A"; } ex.Dispose(); } }
private static CameraProperty ReadFloatProperty(PYLON_DEVICE_HANDLE deviceHandle, string symbol) { CameraProperty p = new CameraProperty(); p.Identifier = symbol; NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle); NODE_HANDLE nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, symbol); if (!nodeHandle.IsValid) { return(p); } EGenApiAccessMode accessMode = GenApi.NodeGetAccessMode(nodeHandle); if (accessMode == EGenApiAccessMode._UndefinedAccesMode || accessMode == EGenApiAccessMode.NA || accessMode == EGenApiAccessMode.NI || accessMode == EGenApiAccessMode.WO) { return(p); } p.Supported = true; p.ReadOnly = accessMode != EGenApiAccessMode.RW; EGenApiNodeType type = GenApi.NodeGetType(nodeHandle); if (type != EGenApiNodeType.FloatNode) { return(p); } p.Type = CameraPropertyType.Float; double min = GenApi.FloatGetMin(nodeHandle); double max = GenApi.FloatGetMax(nodeHandle); EGenApiRepresentation repr = GenApi.FloatGetRepresentation(nodeHandle); double currentValue = GenApi.FloatGetValue(nodeHandle); // We don't support a dedicated control for "pure numbers" just use the regular slider. if (repr == EGenApiRepresentation.PureNumber) { repr = EGenApiRepresentation.Linear; } // Fix values that should be log. double range = Math.Log(max - min, 10); if (range > 4 && repr == EGenApiRepresentation.Linear) { repr = EGenApiRepresentation.Logarithmic; } p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); p.Representation = ConvertRepresentation(repr); p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); return(p); }
public static void Write(SpecificInfo info, CameraProperty property) { if (!property.Supported || string.IsNullOrEmpty(property.Identifier)) { return; } switch (property.Identifier) { case "width": info.Width = int.Parse(property.CurrentValue); break; case "height": info.Height = int.Parse(property.CurrentValue); break; case "framerate": info.Framerate = int.Parse(property.CurrentValue); break; default: log.ErrorFormat("Camera simulator property not supported: {0}.", property.Identifier); break; } }
private static CameraProperty ReadGainBoost(uEye.Camera camera, Dictionary <string, CameraProperty> properties) { bool supported; camera.Gain.Hardware.Boost.GetSupported(out supported); CameraProperty p = new CameraProperty(); p.Identifier = "gainboost"; p.Supported = supported; p.ReadOnly = false; p.Type = CameraPropertyType.Boolean; p.Representation = CameraPropertyRepresentation.Checkbox; if (supported) { bool enable; camera.Gain.Hardware.Boost.GetEnable(out enable); p.CurrentValue = enable ? "true" : "false"; } else { log.DebugFormat("Gain boost is not supported by the camera."); } if (properties != null) { properties.Add(p.Identifier, p); } return(p); }
public static void Write(VideoCaptureDevice device, CameraProperty property) { if (!property.Supported) { return; } switch (property.Specific) { case "CameraControl": { CameraControlProperty p = (CameraControlProperty)Enum.Parse(typeof(CameraControlProperty), property.Identifier, true); WriteProperty(device, p, property); break; } case "VideoProcAmp": { VideoProcAmpProperty p = (VideoProcAmpProperty)Enum.Parse(typeof(VideoProcAmpProperty), property.Identifier, true); WriteProperty(device, p, property); break; } case "Logitech": { WriteLogitechProperty(device, property); break; } } }
void DeviceManager_CameraConnected(ICameraDevice cameraDevice) { CameraProperty property = ServiceProvider.Settings.CameraProperties.Get(cameraDevice); cameraDevice.DisplayName = property.DeviceName; cameraDevice.AttachedPhotoSession = ServiceProvider.Settings.GetSession(property.PhotoSessionName); }
private static CameraProperty ReadGain(uEye.Camera camera, Dictionary <string, CameraProperty> properties) { int gain; camera.Gain.Hardware.Scaled.GetMaster(out gain); CameraProperty p = new CameraProperty(); p.Identifier = "gain"; p.Supported = true; p.ReadOnly = false; p.Type = CameraPropertyType.Float; p.Minimum = "0"; p.Maximum = "100"; p.Step = "1"; p.Representation = CameraPropertyRepresentation.LinearSlider; p.CurrentValue = gain.ToString(CultureInfo.InvariantCulture); if (properties != null) { properties.Add(p.Identifier, p); } return(p); }
private static void WriteExposure(uEye.Camera camera, CameraProperty property) { float value = float.Parse(property.CurrentValue, CultureInfo.InvariantCulture); value /= 1000; camera.Timing.Exposure.Set(value); }
private static CameraProperty ReadExposure(uEye.Camera camera, Dictionary <string, CameraProperty> properties) { uEye.Types.Range <Double> range; camera.Timing.Exposure.GetRange(out range); //camera.Timing.Exposure.Fine.GetRange(out range); // Not supported on test camera. double currentValue; camera.Timing.Exposure.Get(out currentValue); // Switch to microseconds. double min = range.Minimum * 1000; double max = range.Maximum * 1000; double step = range.Increment * 1000; double val = currentValue * 1000; CameraProperty p = new CameraProperty(); p.Identifier = "exposure"; p.Supported = true; p.ReadOnly = false; p.Type = CameraPropertyType.Float; p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); p.Step = step.ToString(CultureInfo.InvariantCulture); p.Representation = CameraPropertyRepresentation.LinearSlider; p.CurrentValue = val.ToString(CultureInfo.InvariantCulture); if (properties != null) { properties.Add(p.Identifier, p); } return(p); }
private static CameraProperty ReadFramerate(uEye.Camera camera, Dictionary <string, CameraProperty> properties) { uEye.Types.Range <Double> range; camera.Timing.Framerate.GetFrameRateRange(out range); double currentValue; camera.Timing.Framerate.Get(out currentValue); CameraProperty p = new CameraProperty(); p.Identifier = "framerate"; p.Supported = true; p.ReadOnly = false; p.Type = CameraPropertyType.Float; p.Minimum = range.Minimum.ToString(CultureInfo.InvariantCulture); p.Maximum = range.Maximum.ToString(CultureInfo.InvariantCulture); p.Step = range.Increment.ToString(CultureInfo.InvariantCulture); p.Representation = CameraPropertyRepresentation.LinearSlider; p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); if (properties != null) { properties.Add(p.Identifier, p); } return(p); }
private static CameraProperty ReadPixelClock(uEye.Camera camera, Dictionary <string, CameraProperty> properties) { uEye.Types.Range <Int32> range; camera.Timing.PixelClock.GetRange(out range); Int32 currentValue; camera.Timing.PixelClock.Get(out currentValue); CameraProperty p = new CameraProperty(); p.Identifier = "pixelclock"; p.Supported = true; p.ReadOnly = false; p.Type = CameraPropertyType.Integer; p.Minimum = range.Minimum.ToString(CultureInfo.InvariantCulture); p.Maximum = range.Maximum.ToString(CultureInfo.InvariantCulture); p.Step = range.Increment.ToString(CultureInfo.InvariantCulture); p.Representation = CameraPropertyRepresentation.LinearSlider; p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); if (properties != null) { properties.Add(p.Identifier, p); } return(p); }
private static void WriteLogitechProperty(VideoCaptureDevice device, CameraProperty value) { if (!value.Supported) { return; } try { int v; bool parsed = int.TryParse(value.CurrentValue, NumberStyles.Any, CultureInfo.InvariantCulture, out v); if (parsed) { device.Logitech_SetExposure(v, !value.Automatic); } else { log.ErrorFormat("Could not parse property {0}, value: {1}.", value.Identifier, value.CurrentValue); } } catch (Exception e) { log.ErrorFormat("Could not write property {0}. {1}.", value.Identifier, e.Message); } }
private void cmb_transfer_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (_loading) { return; } if (ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy) { return; } CameraProperty property = ServiceProvider.DeviceManager.SelectedCameraDevice.LoadProperties(); if ((string)cmb_transfer.SelectedItem == TranslationStrings.LabelTransferItem1 && ServiceProvider.DeviceManager.SelectedCameraDevice.CaptureInSdRam != true) { ServiceProvider.DeviceManager.SelectedCameraDevice.CaptureInSdRam = true; } if ((string)cmb_transfer.SelectedItem == TranslationStrings.LabelTransferItem2) { property.NoDownload = true; ServiceProvider.DeviceManager.SelectedCameraDevice.CaptureInSdRam = false; } if ((string)cmb_transfer.SelectedItem == TranslationStrings.LabelTransferItem3) { property.NoDownload = false; ServiceProvider.DeviceManager.SelectedCameraDevice.CaptureInSdRam = false; } property.CaptureInSdRam = ServiceProvider.DeviceManager.SelectedCameraDevice.CaptureInSdRam; }
/// <summary> /// Commit value of properties that can be written during streaming and don't require a reconnect to be applied. /// This is used by the configuration, to update the image while configuring. /// </summary> public static void Write(PYLON_DEVICE_HANDLE deviceHandle, CameraProperty property) { if (!property.Supported || string.IsNullOrEmpty(property.Identifier) || !deviceHandle.IsValid) { return; } try { switch (property.Identifier) { case "AcquisitionFrameRate": case "AcquisitionFrameRateAbs": case "ExposureTime": case "ExposureTimeAbs": case "Gain": case "GainRaw": WriteProperty(deviceHandle, property); break; case "Width": case "Height": // Do nothing. These properties must be changed from WriteCriticalProperties below. break; default: log.ErrorFormat("Basler property not supported: {0}.", property.Identifier); break; } } catch (Exception e) { log.ErrorFormat("Error while writing Basler property {0}. {1}", property.Identifier, e.Message); } }
private void DeviceManager_CameraSelected(ICameraDevice oldcameraDevice, ICameraDevice newcameraDevice) { if (newcameraDevice == null) { return; } Log.Debug("DeviceManager_CameraSelected 1"); var thread = new Thread(delegate() { CameraProperty property = newcameraDevice.LoadProperties(); // load session data only if not session attached to the selected camera if (newcameraDevice.AttachedPhotoSession == null) { newcameraDevice.AttachedPhotoSession = ServiceProvider.Settings.GetSession(property.PhotoSessionName); } if (newcameraDevice.AttachedPhotoSession != null) { ServiceProvider.Settings.DefaultSession = (PhotoSession)newcameraDevice.AttachedPhotoSession; } }); thread.Start(); Log.Debug("DeviceManager_CameraSelected 2"); }
private static void ReadExposure(Device device, Dictionary <string, CameraProperty> properties) { CameraProperty p = ReadFloatProperty(device, "ExposureTime"); if (!p.Supported) { p = ReadFloatProperty(device, "ExposureTimeAbs"); } string autoIdentifier = "ExposureAuto"; p.AutomaticIdentifier = autoIdentifier; p.CanBeAutomatic = false; p.Automatic = false; bool autoReadable = BaumerHelper.NodeIsReadable(device, p.AutomaticIdentifier); if (autoReadable) { p.CanBeAutomatic = true; string autoValue = BaumerHelper.GetString(device, p.AutomaticIdentifier); p.Automatic = autoValue == GetAutoTrue(autoIdentifier); } properties.Add("exposure", p); }
private static void ReadGain(Device device, Dictionary <string, CameraProperty> properties) { CameraProperty p = ReadFloatProperty(device, "Gain"); if (!p.Supported) { p = ReadIntegerProperty(device, "GainRaw", null); } string autoIdentifier = "GainAuto"; p.AutomaticIdentifier = autoIdentifier; p.CanBeAutomatic = false; p.Automatic = false; bool autoReadable = BaumerHelper.NodeIsReadable(device, p.AutomaticIdentifier); if (autoReadable) { p.CanBeAutomatic = true; string autoValue = BaumerHelper.GetString(device, p.AutomaticIdentifier); p.Automatic = autoValue == GetAutoTrue(autoIdentifier); } properties.Add("gain", p); }
public CameraPropertyRange GetCameraPropertyRange(CameraProperty property) { CameraPropertyRange result; bool successful = false; int minimum, maximum, step, defaults; bool isAuto; minimum = maximum = step = defaults = -1; isAuto = false; lock ( CameraMethodsLock ) { _cameraMethods.GetPropertyRange((WebCamLib.CameraProperty)property, ref minimum, ref maximum, ref step, ref defaults, ref isAuto, ref successful); } if (successful) { result = new CameraPropertyRange(minimum, maximum, step, defaults, isAuto); } else { result = null; } return(result); }
public CameraPropertyValue GetCameraProperty_value(CameraProperty property) { CameraPropertyValue result; bool successful = false; int value = -1; bool isAuto = false; lock ( CameraMethodsLock ) { _cameraMethods.GetProperty_value((WebCamLib.CameraProperty)property, ref value, ref isAuto, ref successful); } if (successful) { result = new CameraPropertyValue(false, value, isAuto); } else { result = null; } return(result); }
private void OnPropertyAutoCheckedStatusChanged(object sender, EventArgs e) { if (m_propInfo.manualSupported && m_propInfo.autoSupported) { try { CameraProperty camProp = m_camera.GetProperty(m_propType); if (m_propInfo.absValSupported) { camProp.absControl = m_isAbsMode; } camProp.autoManualMode = m_propertyAutoCheckBox.Checked; m_camera.SetProperty(camProp); } catch (FC2Exception ex) { Debug.WriteLine(string.Format("Unable to set {0} auto status.", m_propType)); Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); ex.Dispose(); } } m_pauseUpdates = false; m_propertySpinButton.BackColor = System.Drawing.Color.White; }
private void cpvCameraControl_ValueChanged(object sender, EventArgs e) { AbstractCameraPropertyView control = sender as AbstractCameraPropertyView; if (control == null) { return; } string key = control.Tag as string; if (string.IsNullOrEmpty(key) || !cameraProperties.ContainsKey(key)) { return; } CameraProperty property = control.Property; CameraPropertyManager.Write(device, cameraProperties[key]); specificChanged = true; /* * CameraPropertyView cpv = sender as CameraPropertyView; * if (cpv == null) * return; * * CameraControlProperty? property = cpv.Tag as CameraControlProperty?; * if (property == null || !property.HasValue) * return; * * CameraControlFlags flags = cpv.Property.Automatic ? CameraControlFlags.Auto : CameraControlFlags.Manual; * device.SetCameraProperty(property.Value, cpv.Property.Value, flags); */ }
private static void WriteFloat(IGXFeatureControl featureControl, CameraProperty property) { // Commit the auto property first, to flip writeability of the master. if (property.CanBeAutomatic) { if (property.Automatic) { featureControl.GetEnumFeature(property.AutomaticIdentifier).SetValue("Continuous"); } else { featureControl.GetEnumFeature(property.AutomaticIdentifier).SetValue("Off"); } } bool writeable = featureControl.IsWritable(property.Identifier); if (!writeable) { return; } float value = float.Parse(property.CurrentValue, CultureInfo.InvariantCulture); featureControl.GetFloatFeature(property.Identifier).SetValue(value); }
private static void ReadSize(IGXFeatureControl featureControl, Dictionary <string, CameraProperty> properties, string identifier) { bool isImplemented = featureControl.IsImplemented(identifier); bool isReadable = featureControl.IsReadable(identifier); bool isWriteable = featureControl.IsWritable(identifier); CameraProperty p = new CameraProperty(); p.Identifier = identifier; p.Supported = isImplemented && isReadable; p.ReadOnly = !isWriteable; p.Type = CameraPropertyType.Integer; if (!p.Supported) { return; } double value = featureControl.GetIntFeature(identifier).GetValue(); double min = featureControl.GetIntFeature(identifier).GetMin(); double max = featureControl.GetIntFeature(identifier).GetMax(); double step = featureControl.GetIntFeature(identifier).GetInc(); p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); p.Step = step.ToString(CultureInfo.InvariantCulture); p.Representation = CameraPropertyRepresentation.LinearSlider; p.CurrentValue = value.ToString(CultureInfo.InvariantCulture); properties.Add(p.Identifier, p); }
private static void WriteFloat(IGXFeatureControl featureControl, CameraProperty property) { if (property.ReadOnly) { return; } // If auto is switching OFF, we need to set it off before the main prop to make it writeable. // If auto is switching ON, we need to set it ON after the main prop, otherwise it gets turned Off automatically. string currentAutoValue = featureControl.GetEnumFeature(property.AutomaticIdentifier).GetValue(); bool currentAuto = currentAutoValue == GetAutoTrue(property.AutomaticIdentifier); if (property.CanBeAutomatic && currentAuto && !property.Automatic && featureControl.IsWritable(property.AutomaticIdentifier)) { featureControl.GetEnumFeature(property.AutomaticIdentifier).SetValue(GetAutoFalse(property.AutomaticIdentifier)); } float value = float.Parse(property.CurrentValue, CultureInfo.InvariantCulture); if (featureControl.IsWritable(property.Identifier)) { featureControl.GetFloatFeature(property.Identifier).SetValue(value); } if (property.CanBeAutomatic && !currentAuto && property.Automatic && featureControl.IsWritable(property.AutomaticIdentifier)) { featureControl.GetEnumFeature(property.AutomaticIdentifier).SetValue(GetAutoTrue(property.AutomaticIdentifier)); } }
private static CameraProperty ReadIntegerProperty(PYLON_DEVICE_HANDLE deviceHandle, string symbol) { CameraProperty p = new CameraProperty(); p.Identifier = symbol; NODEMAP_HANDLE nodeMapHandle = Pylon.DeviceGetNodeMap(deviceHandle); NODE_HANDLE nodeHandle = GenApi.NodeMapGetNode(nodeMapHandle, symbol); if (!nodeHandle.IsValid) { log.WarnFormat("Could not read Basler property {0}: node handle is not valid. (The property is not supported).", symbol); return(p); } EGenApiAccessMode accessMode = GenApi.NodeGetAccessMode(nodeHandle); if (accessMode == EGenApiAccessMode._UndefinedAccesMode || accessMode == EGenApiAccessMode.NA || accessMode == EGenApiAccessMode.NI || accessMode == EGenApiAccessMode.WO) { log.WarnFormat("Could not read Basler property {0}: Access mode not supported. (The property is not readable).", symbol); return(p); } EGenApiNodeType type = GenApi.NodeGetType(nodeHandle); if (type != EGenApiNodeType.IntegerNode) { log.WarnFormat("Could not read Basler property {0}: the node is of the wrong type. Expected: Integer. Received:{1}", symbol, type.ToString()); return(p); } p.Supported = true; p.Type = CameraPropertyType.Integer; p.ReadOnly = accessMode != EGenApiAccessMode.RW; long min = GenApi.IntegerGetMin(nodeHandle); long max = GenApi.IntegerGetMax(nodeHandle); long step = GenApi.IntegerGetInc(nodeHandle); EGenApiRepresentation repr = GenApi.IntegerGetRepresentation(nodeHandle); // Fix values that should be log. double range = Math.Log10(max) - Math.Log10(min); if (range > 4 && repr == EGenApiRepresentation.Linear) { repr = EGenApiRepresentation.Logarithmic; } long currentValue = GenApi.IntegerGetValue(nodeHandle); p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); p.Step = step.ToString(CultureInfo.InvariantCulture); p.Representation = ConvertRepresentation(repr); p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); return(p); }
private void btn_resetCounters_Click(object sender, RoutedEventArgs e) { foreach (ICameraDevice connectedDevice in ServiceProvider.DeviceManager.ConnectedDevices) { CameraProperty property = ServiceProvider.Settings.CameraProperties.Get(connectedDevice); property.Counter = 0; } }
public bool ValidateCameraProperty(CameraProperty property, int value) { bool result = false; _cameraMethods.ValidatePropertyValue((WebCamLib.CameraProperty)property, value, ref result); return(result); }
public bool CameraPropertyHasRange(CameraProperty property) { bool result = false; _cameraMethods.PropertyHasRange((WebCamLib.CameraProperty)property, ref result); return(result); }
public override void Reset() { base.Reset(); property = CameraProperty.FieldOfView; tweenDirection = TweenDirection.To; targetColor = null; targetFloat = null; }
public void SetProperty(CameraProperty prop, int val, PropertyMode flags) { addLog("SetProperty..."); if (cam == null) { addLog("SetProperty no cam!"); return; } switch (prop) { case CameraProperty.Illumination: if (cam.Features.Torch.Available) cam.Features.Torch.CurrentValue = cam.Features.Torch.MaxValue; break; case CameraProperty.ColorEnable: break; } addLog("SetProperty done"); }