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
andIAMCameraControl
interfaces respectively. That is,IAMVideoProcAmp::Set
andIAMCameraControl::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
= 13KSPROPERTY_CAMERACONTROL_AUTO_EXPOSURE_PRIORITY
= 19