简体   繁体   English

如何更改DirectShow视频的亮度?

[英]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: 有两种更改亮度的方法:

  1. A live source such as video capture card might support 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接口,该接口可能支持亮度调整,然后如果同时提到了两者,则可以控制捕获的视频的亮度
  2. A streaming pipeline might have a decoder/effect filter that changes brightness of video that passes through; 流传输管道可能具有解码器/效果过滤器,可更改通过的视频的亮度。 in particular stock Color Control Transform DSP is capable of doing the task. 尤其是Color Control Transform DSP可以胜任这项任务。 You are certainly supposed to add it to the topology when you build the graph, then update its properties respectively. 当然,应该在构建图形时将其添加到拓扑中,然后分别更新其属性。 This method does not require that input or output device has a special brightness capability. 此方法不需要输入或输出设备具有特殊的亮度功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM