示例#1
0
        internal WebcamProperty GetControlProperties(CameraControlProperty property)
        {
            HResult result = HResult.ERROR_NOT_READY;

            WebcamProperty settings = new WebcamProperty
            {
                _name        = property.ToString(),
                _controlProp = property
            };

            if (_base._webcamMode)
            {
                IAMCameraControl control = _base.mf_MediaSource as IAMCameraControl;
                result = control.GetRange(property, out settings._min, out settings._max, out settings._step, out settings._default, out CameraControlFlags flags);

                if (result == Player.NO_ERROR)
                {
                    settings._supported   = (flags & CameraControlFlags.Manual) != 0;
                    settings._autoSupport = (flags & CameraControlFlags.Auto) != 0;

                    control.Get(property, out settings._value, out flags);
                    settings._auto = (flags & CameraControlFlags.Auto) != 0;
                }
            }
            _base._lastError = result;
            return(settings);
        }
示例#2
0
        public CamSetting(IAMCameraControl filter, CameraControlProperty property)
        {
            _CamFilter   = filter;
            _CamProperty = property;
            _Name        = property.ToString();

            // Update all defaults min max, etc...
            Read();
        }
        private static CameraProperty ReadProperty(VideoCaptureDevice device, CameraControlProperty property)
        {
            CameraProperty p = new CameraProperty();

            p.Identifier     = property.ToString();
            p.Specific       = "CameraControl";
            p.ReadOnly       = false;
            p.Type           = CameraPropertyType.Integer;
            p.Representation = CameraPropertyRepresentation.LinearSlider;
            p.CanBeAutomatic = true;

            try
            {
                int min;
                int max;
                int step;
                int defaultValue;
                CameraControlFlags flags;
                bool success = device.GetCameraPropertyRange(property, out min, out max, out step, out defaultValue, out flags);

                if (!success)
                {
                    p.Supported = false;
                }
                else
                {
                    p.Supported = true;
                    p.Minimum   = min.ToString(CultureInfo.InvariantCulture);
                    p.Maximum   = max.ToString(CultureInfo.InvariantCulture);

                    int currentValue;
                    success = device.GetCameraProperty(property, out currentValue, out flags);

                    if (!success)
                    {
                        p.Supported = false;
                    }
                    else
                    {
                        p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture);
                        p.Automatic    = flags == CameraControlFlags.Auto;
                    }
                }
            }
            catch
            {
                p.Supported = false;
            }

            return(p);
        }
示例#4
0
        public void SetControlProperty(CameraControlProperty prop, int value)
        {
            IAMCameraControl icc = VidControl as IAMCameraControl;

            if (icc != null)
            {
                ControlPropertyInfo info = GetControlPropertyInfo(prop, false);
                if (info != null)
                {
                    if (int.MaxValue == value)
                    {
                        icc.Set(prop, 0, CameraControlFlags.Auto);
                    }
                    else
                    {
                        if (info.IsInRange(value))
                        {
                            icc.Set(prop, value, CameraControlFlags.Manual);
                        }
                    }
                }
                Settings.Get <Settings>().Write(Settings.CAMERA, prop.ToString(), value);
            }
        }