DirectShowLib 应用实例

本文介绍了如何使用DirectShowLib-2005.dll进行视频采集设备的接口操作,包括获取视频设备、初始化接口对象、开始视频预览的详细步骤。通过示例代码展示了设置视频输入设备、创建并配置FilterGraph、SampleGrabber等关键步骤。
摘要由CSDN通过智能技术生成

 

实例引用DirectShowLib-2005.dll,这个DLL可以到http://directshownet.sourceforge.net/直接下载使用。

1、获取视频采集设备IBaseFilter接口对象的方法

//获取所有视频设备名称
public ArrayList GetVideoInputDevice()
      { return GetDeviceCollection(FilterCategory.VideoInputDevice);}
private ArrayList GetDeviceCollection(Guid DeviceType)
      {
          ArrayList returnString = new ArrayList();
          foreach (DsDevice ds in DsDevice.GetDevicesOfCat(DeviceType))
          {
              returnString.Add(ds.Name);
          }
          return returnString;
      }

//通过获取到的视频设备名称设置采集设备的IBaseFilter对象
 public bool SetVideoInputDevice(string VideoInputDeviceName)
      {    //创建视频输入设备接口
          theVideoDevice = CreateFilter(FilterCategory.VideoInputDevice, VideoInputDeviceName); 
      }
//通过过滤器类型和过滤器名称获取IBaseFilter接口
private IBaseFilter CreateFilter(Guid category, string friendlyname)
      {
          object source = null;
          Guid iid = typeof(IBaseFilter).GUID;
          foreach (DsDevice device in DsDevice.GetDevicesOfCat(category))
          {
          

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值