我在我的应用程序中使用 EMGU CV 库。如何手动将相机焦点设置为对象?
现在我使用 Capture 类来抓取图像。
最佳答案
我通过使用 DirectShow 找到了解决方案。通过 IAMCameraControl 接口(interface),我可以控制相机的曝光和对焦。代码示例:
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)