Accord.Video.DirectShow.VideoCaptureDevice.GetCameraProperty C# (CSharp) Method

GetCameraProperty() public method

Gets the current setting of a camera property.
Video source is not specified - device moniker is not set. Failed creating device object for moniker. The video source does not support camera control.
public GetCameraProperty ( CameraControlProperty property, int &value, CameraControlFlags &controlFlags ) : bool
property CameraControlProperty Specifies the property to retrieve.
value int Receives the value of the property.
controlFlags CameraControlFlags Receives the value indicating whether the setting is controlled manually or automatically
return bool
        public bool GetCameraProperty(CameraControlProperty property, out int value, out CameraControlFlags controlFlags)
        {
            bool ret = true;

            // check if source was set
            if ((deviceMoniker == null) || (string.IsNullOrEmpty(deviceMoniker)))
            {
                throw new ArgumentException("Video source is not specified.");
            }

            lock (sync)
            {
                object tempSourceObject = null;

                // create source device's object
                try
                {
                    tempSourceObject = FilterInfo.CreateFilter(deviceMoniker);
                }
                catch
                {
                    throw new ApplicationException("Failed creating device object for moniker.");
                }

                if (!(tempSourceObject is IAMCameraControl))
                {
                    throw new NotSupportedException("The video source does not support camera control.");
                }

                IAMCameraControl pCamControl = (IAMCameraControl)tempSourceObject;
                int hr = pCamControl.Get(property, out value, out controlFlags);

                ret = (hr >= 0);

                Marshal.ReleaseComObject(tempSourceObject);
            }

            return ret;
        }