我一直致力于开发一个 C++ 接口(interface),以通过 Micrsoft Media Foundation 从所有类型的网络摄像头捕获图像。我已经有了一些代码,可以连接多种类型的网络摄像头,并能够捕捉不同分辨率和格式的图像。
我知道在 WinXP 下,可以使用 Direct Show 库更改网络摄像头的不同参数(例如白平衡、曝光时间)。不幸的是,Direct Show 库中可以轻松地从网络摄像头捕获单帧的接口(interface)已从 Win7 下的 Direct Show 中删除。有人知道我如何使用 Microsoft Media Foundation 或我可以与 Microsoft Media Foundation 结合使用的任何其他库来访问这些参数吗?
最佳答案
可以从 WMF 调用 DirectShow QueryInterface 方法。示例代码在 Windows Media Foundation: Controlling Camera Properties 处给出。 . 这应该让您设置可用的相机参数,如焦点和白平衡等。
HRESULT CMFVideoCaptureDlg::SetupCamera(IMFMediaSource* pCameraSource) {
CComQIPtr<IAMCameraControl> spCameraControl(pCameraSource);
HRESULT hr = S_OK;
if(spCameraControl) {
long min, max, step, def, control;
hr = spCameraControl->GetRange(CameraControl_Exposure, &min, &max, &step, &def, &control);
if(SUCCEEDED(hr))
hr = spCameraControl->Set(CameraControl_Exposure, 1, CameraControl_Flags_Manual);
}
CComQIPtr<IAMVideoProcAmp> spVideo(pCameraSource);
if(spVideo)
hr = spVideo->Set(VideoProcAmp_WhiteBalance, 0, VideoProcAmp_Flags_Auto);
return hr;
}
It turns out Media Foundation does not define any specific interfaces for these tasks. Curiously enough, it implements interfaces defined by its predecessor, DirectShow, on its media source (represented by the IMFMediaSource interface), when that media source is a video camera
关于visual-c++ - 微软媒体基金会网络摄像头界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10102843/