简体   繁体   中英

How to access webcam's powerline compensation and back low light compensation settings in DirectShow.Net

I am trying to write a program that will set webcam settings according to a stored preset. I'm using C# and DirectShow.Net. So far I was able to access all the settings sans the ones mentioned.

To read settings I use the following code:

            DsDevice[] capDevices;

            // Get the collection of video devices
            capDevices = 
                DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);

            // Select first camera
            var dev = capDevices[0];

            int hr;

            IBaseFilter capFilter = null;
            ICaptureGraphBuilder2 capGraph = null;

            // Get the graphbuilder object
            IFilterGraph2 m_FilterGraph = (IFilterGraph2)new FilterGraph();
            try
            {
                // Get the ICaptureGraphBuilder2
                capGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();

                /// Start building the graph
                hr = capGraph.SetFiltergraph(m_FilterGraph);
                DsError.ThrowExceptionForHR(hr);

                // Add the video device
                hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, "Video input", out capFilter);
                DsError.ThrowExceptionForHR(hr);

                int value;

                // Reset settings
                cameraSettings.Reset();

                // Get IAMVideoProcAmp Values
                IAMVideoProcAmp pVideoAmp = (IAMVideoProcAmp)capFilter;
                VideoProcAmpFlags vpaFlags;

                pVideoAmp.Get(VideoProcAmpProperty.Brightness, out value, out vpaFlags);

                .....

                // Get IAMCameraControl Values
                IAMCameraControl pCameraControl = (IAMCameraControl)capFilter;
                CameraControlFlags ccFlags;

                pCameraControl.Get(CameraControlProperty.Exposure, out value, out ccFlags);

                .....

However, neither of the interfaces allows getting those two values. I will attach a screenshot that shows those values accessible in the typical windows interface for webcam settings:

How can I access those values via DirectShow.Net?

These property pages are communicating with the filter objects using IAMVideoProcAmp and IAMCameraControl interfaces respectively. That is, IAMVideoProcAmp::Set and IAMCameraControl::Set are the methods called by property page implementation and they can similarly be used by applications programmatically.

Property enumerations do not have defined values for powerline frequency and low light compensation because SDK and documentation was no longer updated to indicate values from extended enumerations, however new properties do exist. Specifically, they exist in stock property pages implementation.

The named and documented property values are available from lower layer SDK definitions:

  • KSPROPERTY_VIDEOPROCAMP_POWERLINE_FREQUENCY = 13
  • KSPROPERTY_CAMERACONTROL_AUTO_EXPOSURE_PRIORITY = 19

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM