首先,让我首先说我对DirectShow的了解几乎为零。但我的任务是调整从帧抓取卡中捕获的视频的亮度。
我正在使用DirectShow.NET和WPFMediaKit,所以这就是我获取视频的方式:
DirectShowLib.DsDevice[] allDevices = WPFMediaKit.DirectShow.Controls.MultimediaUtil.VideoInputDevices;
DirectShowLib.DsDevice dev = allDevices.ElementAt(0);
这就是我调整亮度的方法:
//Get the IAMVideoProcAmp
object o;
Guid IID_IBaseFilter = new Guid("56a86895-0ad4-11ce-b03a-0020af0ba770");
dev.Mon.BindToObject(null, null, ref IID_IBaseFilter, out o);
DirectShowLib.IAMVideoProcAmp vpa = (DirectShowLib.IAMVideoProcAmp)o;
//Get the flags
int pMin, pMax, pSteppingDelta, pDefault, pCurrent;
DirectShowLib.VideoProcAmpFlags pFlags;
vpa.GetRange(DirectShowLib.VideoProcAmpProperty.Brightness, out pMin, out pMax, out pSteppingDelta, out pDefault, out pFlags);
vpa.Get(DirectShowLib.VideoProcAmpProperty.Brightness, out pCurrent, out pFlags);
//Set the slider
brightnessSlider.Maximum = pMax;
brightnessSlider.Minimum = pMin;
brightnessSlider.Value = pCurrent;
该代码适用于我的网络摄像头。但是,当我尝试在帧抓取卡的视频上执行此操作时,会显示以下错误:
Unable to cast COM object of type 'System.__ComObject' to interface type 'DirectShowLib.IAMVideoProcAmp'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C6E13360-30AC-11D0-A18C-00A0C9118956}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
......在这一行:
DirectShowLib.IAMVideoProcAmp vpa = (DirectShowLib.IAMVideoProcAmp)o;
知道如何修复它或调整来自帧抓取卡的视频的亮度吗?
答案 0 :(得分:1)
有两种方法可以改变亮度:
IAMVideoProcAmp
界面,可能支持亮度调整,然后如果你有两个提到的,你可以控制被捕获的视频的亮度