介绍
最近手上拿到一款带按键的USB摄像头,按照我们的思维,是不是有个特定的控件获取按键信号事件,结果不是,在windows下的DirectShow下是个标准功能,下面就是介绍开发中遇到的一些问题记录:
1.在DirectShow中功能描述
里面这个比较关键,USB Camera有两个Pin,Capture pin和Still pin,Capture pin用于视频流预览,Still pin用于响应抓拍(可以软触发和硬件触发)
hr = pBuild->RenderStream(
&PIN_CATEGORY_STILL, // Connect this pin ...
&MEDIATYPE_Video, // with this media type ...
pCap, // on this filter ...
pSG_Filter, // to the Sample Grabber ...
pNull); // ... and finally to the Null Renderer.
2.SetMediaType 函数不要调用,否则Still Pin 会一直触发
类似这样的操作不要调用
AM_MEDIA_TYPE amt = {0};
amt.majortype = MEDIATYPE_Video;
amt.subtype = sub_type;