Created
April 6, 2018 01:10
-
-
Save anotherlab/953a5361c1db705ecc42d6e9fef13d29 to your computer and use it in GitHub Desktop.
Creating a video capture filter with DirectShow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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