I am using EMGU CV library in my application. How i can manually set camera focus to object? Now i'm using Capture class for grab images.
I found the solution by using DirectShow. By IAMCameraControl interface i can control exposure and focusing of camera. Code sample:
DsDevice[] devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); // getting video devices
IFilterGraph2 graphBuilder = new FilterGraph() as IFilterGraph2;
IBaseFilter capFilter = null;
if (graphBuilder != null)
graphBuilder.AddSourceFilterForMoniker(devs[0].Mon, null, devs[0].Name,
out capFilter); //getting capture filter for converting it into IAMCameraControl
IAMCameraControl _camera = capFilter as IAMCameraControl;
_camera.Set(CameraControlProperty.Focus, 250, CameraControlFlags.Manual); //Setting focus to macro (in my camera, range between 0 - 250)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With