Microsoft Media Foundation Webcam Interface
I've been working on a c++ interface to capture images from all types of webcams via the Micrsoft Media Foundation. I've already got a bit of code that can connect with several types of webcams and is able to capture images in different resolutions and formats.
I know that under WinXP it is possible to change different parameters of the webcam (like white balance, exposure time eg) by using the Direct Show library. Unfortunately the interface in the Direct Show library that made it possible to easily capture single frames from a webcam is removed from Direct Show under Win7. Does anybody know how I can acces these parameters using Microsoft Media Foundation or any other library that I can combine with the Microsoft Media Foundation?
DirectShow
is still good in Windows 7 (the easiest to check is using GraphEdit
and AMCap
from Windows SDK). Media Foundation however lacks essential support in earlier versions of Windows.
It is possible to call a DirectShow QueryInterface method from WMF. Example code is given at Windows Media Foundation: Controlling Camera Properties. This should let you set available camera parameters like focus and white balance etc.
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
IAMCameraControl和IANVideoProcAmp仍然支持Windows 8中的白平衡,平移,缩放。相机控制至今不是MFT的一部分。我们必须使用Direct Show来完成这些操作。
链接地址: http://www.djcxy.com/p/80976.html上一篇: OpenCV摄像头与libusb驱动程序python
下一篇: 微软媒体基金会Webcam界面