Beispiel #1
0
        public FormConfiguration(CameraSummary summary)
        {
            this.summary    = summary;
            this.identifier = summary.Identifier;

            InitializeComponent();
            tbAlias.AutoSize = false;
            tbAlias.Height   = 20;

            tbAlias.Text            = summary.Alias;
            lblSystemName.Text      = summary.Name;
            btnIcon.BackgroundImage = summary.Icon;

            InitializeMediaTypes(summary);

            if (canStreamConfig)
            {
                PopulateFormats();
            }
            else
            {
                DisableStreamConfig();
            }

            streamConfigInitialized = true;

            cameraProperties = CameraPropertyManager.Read(device);
            PopulateCameraControl();
            Localize();
        }
Beispiel #2
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;
            }

            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 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;
        }
Beispiel #4
0
        /// <summary>
        /// Configure the device according to what is saved in the preferences for it.
        /// </summary>
        private void ConfigureDevice()
        {
            SpecificInfo info = summary.Specific as SpecificInfo;

            if (info == null || info.MediaTypeIndex < 0)
            {
                log.DebugFormat("No configuration saved in preferences for this device.");
                return;
            }

            // Initialize device configuration (Extract and cache media types on the output pin).
            // Double check we have an existing index and set the format.
            AForge.Video.DirectShow.VideoCapabilities[] capabilities = device.VideoCapabilities;
            AForge.Video.DirectShow.VideoCapabilities   match        = capabilities.FirstOrDefault(c => c.Index == info.MediaTypeIndex);
            if (match == null)
            {
                log.ErrorFormat("Could not match the saved media type.");
                return;
            }

            device.SetMediaTypeAndFramerate(info.MediaTypeIndex, info.SelectedFramerate);

            log.DebugFormat("Device set to saved configuration: Index:{0}. ({1}×{2} @ {3:0.###} fps ({4})).",
                            info.MediaTypeIndex, match.FrameSize.Width, match.FrameSize.Height, info.SelectedFramerate, match.Compression);

            // Reload camera properties in case the firmware "forgot" them.
            // This means changes done in other softwares will be overwritten.
            try
            {
                CameraPropertyManager.Write(device, info.CameraProperties);
            }
            catch
            {
                log.ErrorFormat("An error occured while reloading camera properties.");
            }
        }