[英]How to change brightness of DirectShow video?
首先,讓我首先說一下我對DirectShow的了解幾乎為零。 但是我的任務是調整從Frame Grabber卡捕獲的視頻的亮度。
我正在使用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;
知道如何解決它或調整來自圖像采集卡的視頻的亮度嗎?
有兩種更改亮度的方法:
IAMVideoProcAmp
接口,該接口可能支持亮度調整,然后如果同時提到了兩者,則可以控制捕獲的視頻的亮度
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.