public FormConfiguration(CameraSummary summary) { this.summary = summary; InitializeComponent(); tbAlias.AutoSize = false; tbAlias.Height = 20; tbAlias.Text = summary.Alias; lblSystemName.Text = summary.Name; btnIcon.BackgroundImage = summary.Icon; SpecificInfo specific = summary.Specific as SpecificInfo; if (specific == null || specific.Camera == null || !specific.Camera.IsOpened) { return; } camera = specific.Camera; int temp; camera.Device.GetDeviceID(out temp); deviceId = (long)temp; cameraProperties = CameraPropertyManager.Read(camera, deviceId); if (cameraProperties.Count != specific.CameraProperties.Count) { specificChanged = true; } Populate(); }
private void ReloadProperty(string key) { if (!propertiesControls.ContainsKey(key) || !cameraProperties.ContainsKey(key)) { return; } // Reload the property in case the range or current value changed. CameraProperty prop = CameraPropertyManager.Read(camera, deviceId, key); if (prop == null) { return; } cameraProperties[key] = prop; propertiesControls[key].Repopulate(prop); }
public FormConfiguration(CameraSummary summary, Action disconnect, Action connect) { this.summary = summary; this.disconnect = disconnect; this.connect = connect; InitializeComponent(); tbAlias.AutoSize = false; tbAlias.Height = 20; tbAlias.Text = summary.Alias; lblSystemName.Text = summary.Name; btnIcon.BackgroundImage = summary.Icon; btnReconnect.Text = CameraLang.FormConfiguration_Reconnect; btnImport.Text = CameraLang.FormConfiguration_ImportParameters; SpecificInfo specific = summary.Specific as SpecificInfo; if (specific == null || specific.Camera == null || !specific.Camera.IsOpened) { return; } camera = specific.Camera; int temp; camera.Device.GetDeviceID(out temp); deviceId = (long)temp; cameraProperties = CameraPropertyManager.Read(camera, deviceId); if (cameraProperties.Count != specific.CameraProperties.Count) { specificChanged = true; } Populate(); this.Text = CameraLang.FormConfiguration_Title; btnApply.Text = CameraLang.Generic_Apply; }
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; } CameraPropertyManager.Write(camera, deviceId, control.Property); // Dependencies: // - Pixel clock changes the range and current value of framerate. // - Framerate changes the range and current value of exposure. if (key == "height" || key == "width") { ReloadProperty("framerate"); ReloadProperty("exposure"); } else if (key == "pixelclock") { ReloadProperty("framerate"); ReloadProperty("exposure"); } else if (key == "framerate") { ReloadProperty("exposure"); } specificChanged = true; }
private void Open() { // Unlike in the DirectShow module, we do not backup and restore camera configuration. // If the user configured the camera outside of Kinovea we respect the new settings. // Two reasons: // 1. In DirectShow we must do the backup/restore to work around drivers that inadvertently reset the camera properties. // 2. Industrial cameras have many properties that won't be configurable in Kinovea // so the user is more likely to configure the camera from the outside. if (grabbing) { Stop(); } try { uEye.Defines.Status status = camera.Init((Int32)deviceId | (Int32)uEye.Defines.DeviceEnumeration.UseDeviceID); if (status != uEye.Defines.Status.SUCCESS) { log.ErrorFormat("Error trying to open IDS uEye camera."); return; } // Load parameter set. ProfileHelper.Load(camera, summary.Identifier); } catch (Exception e) { log.Error("Could not open IDS uEye camera.", e); 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.Camera = camera; int currentColorMode = IDSHelper.ReadCurrentStreamFormat(camera); // Some properties can only be changed when the camera is opened but not streaming. Now is the time. // We store them in the summary when coming back from FormConfiguration, and we write them to the camera here. // Only do this if it's not the first time we open the camera, to respect any change that could have been done outside Kinovea. if (firstOpen) { specific.StreamFormat = currentColorMode; } else { if (specific.StreamFormat != currentColorMode) { IDSHelper.WriteStreamFormat(camera, specific.StreamFormat); } CameraPropertyManager.WriteCriticalProperties(camera, specific.CameraProperties); // Save parameter set. ProfileHelper.Save(camera, ProfileHelper.GetProfileFilename(summary.Identifier)); } // Reallocate IDS internal buffers after changing the format. Int32[] memList; camera.Memory.GetList(out memList); camera.Memory.Free(memList); camera.Memory.Allocate(); int memId; camera.Memory.GetActive(out memId); int width, height, bitsPerPixel, pitch; camera.Memory.Inquire(memId, out width, out height, out bitsPerPixel, out pitch); log.DebugFormat("IDS internal buffers allocated: {0}x{1}, {2} bits per pixel, pitch:{3}.", width, height, bitsPerPixel, pitch); }
private void BtnImport_Click(object sender, EventArgs e) { // Locate an .ini file. OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = CameraLang.FormConfiguration_ImportParameters; //openFileDialog.InitialDirectory = Path.GetDirectoryName(ProfileHelper.GetProfileFilename(summary.Identifier)); openFileDialog.RestoreDirectory = true; openFileDialog.Filter = "Ini file (*.ini)" + "|*.ini;"; openFileDialog.FilterIndex = 0; if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } string filename = openFileDialog.FileName; if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) { return; } // The timing here is finnicky. // connect() will start the delay buffer allocation on the current image size and start receiving frames. // disconnect prevents reading the new values from the camera. // Load with new sizes while the camera is streaming will fail because the buffers are wrong. // So we need to load the new values with the camera opened but not streaming. this.SuspendLayout(); disconnect(); ProfileHelper.Replace(summary.Identifier, filename); // Reopen the camera but do not start grabbing. uEye.Defines.Status status = camera.Init((Int32)deviceId | (Int32)uEye.Defines.DeviceEnumeration.UseDeviceID); if (status != uEye.Defines.Status.SUCCESS) { log.ErrorFormat("Error trying to open IDS uEye camera."); return; } // Load new parameters. ProfileHelper.Load(camera, summary.Identifier); cameraProperties = CameraPropertyManager.Read(camera, deviceId); SpecificInfo info = summary.Specific as SpecificInfo; PopulateStreamFormat(); info.StreamFormat = this.SelectedStreamFormat.Value; info.CameraProperties = cameraProperties; summary.UpdateDisplayRectangle(Rectangle.Empty); CameraTypeManager.UpdatedCameraSummary(summary); // Reconnect. camera.Exit(); connect(); // Reload UI. RemoveCameraControls(); PopulateCameraControls(); this.ResumeLayout(); }