关于DirectShowLib视频采集的用法。高手进来帮帮忙

vipxiaoma 2013-08-03 04:03:03
DirectShowLib视频采集

 try
{

int hr = 0;
hr = this.m_graphBuilder.AddFilter(theVideoDevice, "Video Capture");
DsError.ThrowExceptionForHR(hr);

// 通过theVideoDevice(IBaseFilter)视频接口对象的Preview Pin预览
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Video, theVideoDevice, null, null);
//DsError.ThrowExceptionForHR(hr);

//插入SampleGrabber
m_pinStill = DsFindPin.ByCategory(theVideoDevice, PinCategory.Still, 0);

if (m_pinStill == null)
{
m_pinStill = DsFindPin.ByCategory(theVideoDevice, PinCategory.Capture, 0);
}


// 获取theVideoDevice的IAMVideoControl对象,对于具有Still Pin的对象可以获到,采集设备不具备Still Pin,那么该对象将为Null
m_VidControl = theVideoDevice as IAMVideoControl;

// 设置采集视频参数
//if (this.Height + this.Width + this.Width > 0)
//{
// SetConfigParms(m_pinStill, this.Width, this.Height, 24);
//}

//开始拍照功能所需的接口对象
// 获得SampleGrabber对象接口
sampGrabber = new SampleGrabber() as ISampleGrabber;

// 配置sample grabber
baseGrabFlt = sampGrabber as IBaseFilter;
// ConfigureSampleGrabber(sampGrabber);

// 将sample grabber添加到图形过滤器中
hr = m_graphBuilder.AddFilter(baseGrabFlt, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);

// //通过渲染将采集设备的相关输出Pin与sample grabber对象的输入Pin连接起来
// //如果采集设备提供Still Pin,则通过Still Pin连接,否则直接使用Capture Pin连接
if (m_VidControl != null)
{
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Still, MediaType.Video, theVideoDevice, null, baseGrabFlt);
DsError.ThrowExceptionForHR(hr);

}
else
{
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Capture, MediaType.Video, theVideoDevice, null, baseGrabFlt);
DsError.ThrowExceptionForHR(hr);
}

// //设置抓取图片相关参数
// // SaveSizeInfo(sampGrabber);
// //拍照功能所需的接口对象添加结束


//// 开始将视频窗口绑定到主窗体上
hr = this.m_videoWindow.put_Owner(this.Handle);

hr = this.m_videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren);

if (this.m_videoWindow != null)
{
this.m_videoWindow.SetWindowPosition(0, 0, this.Width, this.Height);
}

//hr = this.m_videoWindow.put_Visible(OABool.True);

//// 开始预览采集设备采集到的视频
hr = this.m_mediaControl.Run();

}
catch
{
throw new Exception("VideoPreview函数出现异常,视频预览失败!");

}



请问代码中
 if (m_VidControl != null)
{
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Still, MediaType.Video, theVideoDevice, null, baseGrabFlt);
DsError.ThrowExceptionForHR(hr);

}
else
{
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Capture, MediaType.Video, theVideoDevice, null, baseGrabFlt);
DsError.ThrowExceptionForHR(hr);
}
是否用来采集视频流?
...全文
157 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yan2345678 2014-07-02
  • 打赏
  • 举报
回复
有全面的资料吗
wsydm110 2013-08-30
  • 打赏
  • 举报
回复
还有这个类里面的
public static class PinCategory
    {
        public static readonly Guid AnalogVideoIn;
        public static readonly Guid Capture;
        public static readonly Guid CC;
        public static readonly Guid EDS;
        public static readonly Guid NABTS;
        public static readonly Guid Preview;
        public static readonly Guid Still;
        public static readonly Guid TeleText;
        public static readonly Guid TimeCode;
        public static readonly Guid VBI;
        public static readonly Guid VideoPort;
        public static readonly Guid VideoPortVBI;
    }
这些都是什么意思啊?
wsydm110 2013-08-30
  • 打赏
  • 举报
回复
...哥们我也在做这个,请问你DsFindPin.ByCategory这个函数是干什么用的,还有你是在哪查看一些函数的文档啊?我怕google都搜不到

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧