如何编程禁用网络摄像头的自动对焦? [英] How to programatically disable the auto-focus of a webcam?

查看:1187
本文介绍了如何编程禁用网络摄像头的自动对焦?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用网络摄像头进行计算机视觉(模型是Hercules Dualpix)。我知道这不是理想的相机使用,但我没有选择在这里。

I am trying to do computer vision using a webcam (the model is Hercules Dualpix). I know it is not the ideal camera to use, but I have no choice here.

问题是自动对焦使得难以或不可能校准相机。任何人都知道一种方法来禁用自动对焦功能。

The problem is the auto-focus makes it hard/impossible to calibrate the camera. Anyone knows a way to disable the auto-focus feature. Or, if someone has an idea to deal with it and calibrate the camera with the auto-focus.

推荐答案

大力神照相机是一种自动对焦功能,符合UVC,因此他们应该使用DirectShow接口 IAMCameraControl 。您可以将焦点设置为特定的值,并使用标志设置您不希望它是自动的。您可以使用 IAMCameraControl :: Get 轮询当前状态,因为并非所有摄像机都支持关闭焦点。

The Hercules cameras are UVC compliant, so they should work with the DirectShow Interface IAMCameraControl. You can set the focus to a specific value, and use the flags to set that you do not want it to be automatic. You can use IAMCameraControl::Get to poll the current state, because not all cameras do support turning off the focus.

IAMCameraControl *pCameraControl; 
HRESULT hr; 
hr = pFilter->QueryInterface(IID_IAMCameraControl, (void **)&pCameraControl); 
if (hr == S_OK) {
  long defaultFocusValue;
  hr = pCameraControl->GetRange(CameraControl_Focus,
                                NULL, // min
                                NULL, // max
                                NULL, // minstep
                                &defaultFocusValue, // default
                                NULL); // capflags
  hr = pCameraControl->Set(CameraControl_Focus, // property
                           defaultFocusValue, // value
                           CameraControl_Flags_Manual); 
}

焦点具有由每个摄像机分别定义的范围,因此您应该查询它如图所示找到默认值和min,max如果你想要的。
在这个例子中, pFilter 是一个指向您从DirectShow输入过滤器的指针。您可以枚举设备并找到您想要的设备。

Focus has a range which is defined by each camera separately, so you should query it as shown to find the default value and the min, max if you want. In this example the pFilter is a pointer to the input filter that you have from DirectShow. You can get it by enumerating the devices and finding the one you want.

这篇关于如何编程禁用网络摄像头的自动对焦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆