实例引用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))
{