private void PopulateStreamFormat() { lblColorSpace.Text = CameraLang.FormConfiguration_Properties_StreamFormat; // Get the intersection of camera and Kinovea supported formats. List <IDSEnum> streamFormats = IDSHelper.GetSupportedStreamFormats(camera, deviceId); // Get currently selected option. int currentColorMode = IDSHelper.ReadCurrentStreamFormat(camera); cmbFormat.Items.Clear(); foreach (IDSEnum streamFormat in streamFormats) { cmbFormat.Items.Add(streamFormat); if (streamFormat.Value == currentColorMode) { selectedStreamFormat = streamFormat; cmbFormat.SelectedIndex = cmbFormat.Items.Count - 1; } } // TODO: if the current camera format is not supported in Kinovea, force the camera to switch to a supported mode. // What if none of the Kinovea modes are supported by the camera ? }
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); }