Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Creating a video capture filter with DirectShow
if (new FilterGraph() is IFilterGraph2 graphBuilder)
{
// Create a video capture filter for the device
graphBuilder.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out IBaseFilter capFilter);
// Cast that filter to IAMCameraControl from the DirectShowLib
IAMCameraControl _camera = capFilter as IAMCameraControl;
// Get the current focus settings from the webcam
_camera.Get(CameraControlProperty.Focus, out int v, out CameraControlFlags f);
// If the camera was not in manual focus mode, lock it into manual at the current focus setting
if (f != CameraControlFlags.Manual)
{
_camera.Set(CameraControlProperty.Focus, v, CameraControlFlags.Manual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment