Skip to content

Instantly share code, notes, and snippets.

@anotherlab
Created April 6, 2018 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anotherlab/953a5361c1db705ecc42d6e9fef13d29 to your computer and use it in GitHub Desktop.
Save anotherlab/953a5361c1db705ecc42d6e9fef13d29 to your computer and use it in GitHub Desktop.
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