コード例 #1
0
        private void Open()
        {
            if (grabbing)
            {
                Stop();
            }

            try
            {
                baumerProvider.Open(specific.SystemKey, specific.InterfaceKey, specific.DeviceKey);
            }
            catch (Exception e)
            {
                log.Error("Could not open Baumer device.");
                LogError(e, "");
                return;
            }

            if (!baumerProvider.IsOpen)
            {
                return;
            }

            // Store the device into the specific info so that we can retrieve device informations from the configuration dialog.
            specific.Device = baumerProvider.Device;

            if (!string.IsNullOrEmpty(specific.StreamFormat))
            {
                BaumerHelper.WriteEnum(specific.Device, "PixelFormat", specific.StreamFormat);
            }

            if (firstOpen)
            {
                // Restore camera parameters from the XML blurb.
                // Regular properties, including image size.
                // First we read the current properties from the API to get fully formed properties.
                // We merge the values saved in the XML into the properties.
                // (The restoration from the XML doesn't create fully formed properties, it just contains the values).
                // Then commit the properties to the camera.
                Dictionary <string, CameraProperty> cameraProperties = CameraPropertyManager.Read(specific.Device, summary.Identifier);
                CameraPropertyManager.MergeProperties(cameraProperties, specific.CameraProperties);
                specific.CameraProperties = cameraProperties;
                CameraPropertyManager.WriteCriticalProperties(specific.Device, specific.CameraProperties);
            }
            else
            {
                CameraPropertyManager.WriteCriticalProperties(specific.Device, specific.CameraProperties);
            }
        }
コード例 #2
0
        private void BtnReconnect_Click(object sender, EventArgs e)
        {
            if (SelectedStreamFormat == null)
            {
                // This happens when we load the config window and the camera isn't connected.
                return;
            }

            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info == null)
            {
                return;
            }

            info.StreamFormat     = this.SelectedStreamFormat;
            info.Demosaicing      = this.Demosaicing;
            info.Compression      = this.Compression;
            info.CameraProperties = this.CameraProperties;
            summary.UpdateDisplayRectangle(Rectangle.Empty);
            CameraTypeManager.UpdatedCameraSummary(summary);

            disconnect();
            connect();

            SpecificInfo specific = summary.Specific as SpecificInfo;

            if (specific == null || specific.Device == null || !specific.Device.IsOpen)
            {
                return;
            }

            device           = specific.Device;
            cameraProperties = CameraPropertyManager.Read(device, summary.Identifier);

            RemoveCameraControls();

            PopulateStreamFormat();
            PopulateBayerConversion();
            PopulateCompression();
            PopulateCameraControls();

            UpdateResultingFramerate();
        }
コード例 #3
0
        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(device, cameraProperties[key]);
            UpdateResultingFramerate();
            specificChanged = true;
        }
コード例 #4
0
        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;

            SpecificInfo specific = summary.Specific as SpecificInfo;

            if (specific == null || specific.Device == null || specific.Device.Id == null || !specific.Device.IsOpen)
            {
                return;
            }

            device           = specific.Device;
            cameraProperties = CameraPropertyManager.Read(device, summary.Identifier);
            if (cameraProperties.Count != specific.CameraProperties.Count)
            {
                specificChanged = true;
            }

            demosaicing = specific.Demosaicing;
            compression = specific.Compression;

            Populate();
            this.Text     = CameraLang.FormConfiguration_Title;
            btnApply.Text = CameraLang.Generic_Apply;
            UpdateResultingFramerate();
        }