[英]How to change brightness of DirectShow video?
First of all, let me start by saying I have almost zero knowledge of DirectShow. 首先,让我首先说一下我对DirectShow的了解几乎为零。 But I'm task to adjust the brightness of a video that is captured from a Frame Grabber Card.
但是我的任务是调整从Frame Grabber卡捕获的视频的亮度。
I am using DirectShow.NET and WPFMediaKit, so this is how I get the video: 我正在使用DirectShow.NET和WPFMediaKit,所以这是我获得视频的方式:
DirectShowLib.DsDevice[] allDevices = WPFMediaKit.DirectShow.Controls.MultimediaUtil.VideoInputDevices;
DirectShowLib.DsDevice dev = allDevices.ElementAt(0);
This is how I adjust the brightness: 这是我调整亮度的方法:
//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;
The code does work for my webcam. 该代码确实适用于我的网络摄像头。 However, when I try to do it on a video from the frame grabber card, it displays the following error:
但是,当我尝试对来自图像采集卡的视频进行处理时,它显示以下错误:
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)).
... at this line: ...在这一行:
DirectShowLib.IAMVideoProcAmp vpa = (DirectShowLib.IAMVideoProcAmp)o;
Any idea how to fix it or adjust the brightness from this video that came from the frame grabber card? 知道如何解决它或调整来自图像采集卡的视频的亮度吗?
There are two ways to change brightness: 有两种更改亮度的方法:
IAMVideoProcAmp
interface, which might support brightness adjustment, and then if you have the both mentioned you can control the brightness of video being captured IAMVideoProcAmp
接口,该接口可能支持亮度调整,然后如果同时提到了两者,则可以控制捕获的视频的亮度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.