Esempio n. 1
0
        private void PopulateCameraControl()
        {
            int top = lblAuto.Bottom;

            if (cameraProperties.ContainsKey("exposure_logitech"))
            {
                AddCameraProperty("exposure_logitech", CameraLang.FormConfiguration_Properties_Exposure, VendorHelper.GetValueMapper(identifier, "exposure_logitech"), top);
            }
            else if (cameraProperties.ContainsKey("exposure"))
            {
                AddCameraProperty("exposure", CameraLang.FormConfiguration_Properties_Exposure, VendorHelper.GetValueMapper(identifier, "exposure"), top);
            }

            AddCameraProperty("gain", CameraLang.FormConfiguration_Properties_Gain, VendorHelper.GetValueMapper(identifier, "gain"), top + 30);
            AddCameraProperty("focus", CameraLang.FormConfiguration_Properties_Focus, VendorHelper.GetValueMapper(identifier, "focus"), top + 60);
        }
Esempio n. 2
0
        public override List <CameraSummary> DiscoverCameras(IEnumerable <CameraBlurb> blurbs)
        {
            // DirectShow has active discovery. We just ask for the list of cameras connected to the PC.
            List <CameraSummary> summaries = new List <CameraSummary>();
            List <CameraSummary> found     = new List <CameraSummary>();

            FilterInfoCollection cameras = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo camera in cameras)
            {
                if (bypass.Contains(camera.Name))
                {
                    continue;
                }

                // For now consider that the moniker string is like a serial number.
                // Cameras that don't have a serial number will appear to be new when changing USB port.
                string identifier = camera.MonikerString;
                bool   cached     = cache.ContainsKey(identifier);

                string             alias            = camera.Name;
                Bitmap             icon             = null;
                SpecificInfo       specific         = null;
                Rectangle          displayRectangle = Rectangle.Empty;
                CaptureAspectRatio aspectRatio      = CaptureAspectRatio.Auto;

                if (blurbs != null)
                {
                    foreach (CameraBlurb blurb in blurbs)
                    {
                        if (blurb.CameraType != this.CameraType || blurb.Identifier != identifier)
                        {
                            continue;
                        }

                        alias            = blurb.Alias;
                        icon             = blurb.Icon ?? SelectDefaultIcon(identifier);
                        displayRectangle = blurb.DisplayRectangle;
                        if (!string.IsNullOrEmpty(blurb.AspectRatio))
                        {
                            aspectRatio = (CaptureAspectRatio)Enum.Parse(typeof(CaptureAspectRatio), blurb.AspectRatio);
                        }

                        specific = SpecificInfoDeserialize(blurb.Specific);
                        VendorHelper.IdentifyModel(identifier);
                        break;
                    }
                }

                if (icon == null)
                {
                    icon = SelectDefaultIcon(identifier);
                }

                CameraSummary summary = new CameraSummary(alias, camera.Name, identifier, icon, displayRectangle, aspectRatio, specific, this);
                summaries.Add(summary);

                if (cached)
                {
                    found.Add(cache[identifier]);
                }

                if (!cached)
                {
                    cache.Add(identifier, summary);
                    found.Add(summary);
                    log.DebugFormat("DirectShow device enumeration: {0} (moniker:{1}).", summary.Alias, identifier);
                }
            }

            // TODO: do we need to do all this. Just replace the cache with the current list.

            List <CameraSummary> lost = new List <CameraSummary>();

            foreach (CameraSummary summary in cache.Values)
            {
                if (!found.Contains(summary))
                {
                    lost.Add(summary);
                }
            }

            foreach (CameraSummary summary in lost)
            {
                cache.Remove(summary.Identifier);
            }

            return(summaries);
        }
        private void PopulateCameraControl()
        {
            int  top   = lblAuto.Bottom;
            bool added = false;

            if (cameraProperties.ContainsKey("exposure_logitech"))
            {
                added = AddCameraProperty("exposure_logitech", CameraLang.FormConfiguration_Properties_Exposure, VendorHelper.GetValueMapper(identifier, "exposure_logitech"), top);
            }
            else if (cameraProperties.ContainsKey("exposure"))
            {
                added = AddCameraProperty("exposure", CameraLang.FormConfiguration_Properties_Exposure, VendorHelper.GetValueMapper(identifier, "exposure"), top);
            }

            top  += (added ? 30 : 0);
            added = AddCameraProperty("gain", CameraLang.FormConfiguration_Properties_Gain, null, top);
            top  += (added ? 30 : 0);
            AddCameraProperty("focus", CameraLang.FormConfiguration_Properties_Focus, null, top);
        }