[英]How to disconnect from the webcam using directshow?
I used directshow.net
with my web-cam and it worked so well. 我将directshow.net
与网络摄像头一起使用,效果很好。 But when I closed the form and opened it again, it gives me an error in the method SetupGraph()
because the value that come from the next code line is negative. 但是,当我关闭窗体并再次打开它时,它在SetupGraph()
方法中给了我一个错误,因为来自下一条代码行的值是负数。
hr = capGraph.RenderStream(ref cat, ref med, capFilter, null, null);
but when I unplugged my camera, it works good the second time. 但是当我拔下相机电源时,第二次效果很好。
I hope it's not a big deal. 我希望这没什么大不了的。
You can try to call yourMediaControl.StopWhenReady()
method and after that release all com object instances like graph
, source
, grabber
, capture graph
with Marshal.ReleaseComObject . 您可以尝试调用yourMediaControl.StopWhenReady()
方法,然后使用Marshal.ReleaseComObject释放所有com对象实例,例如graph
, source
, grabber
, capture graph
。
The IMediaControl.StopWhenReady method pauses the filter graph, allowing filters to queue data, and then stops the filter graph. IMediaControl.StopWhenReady方法暂停过滤器图,允许过滤器将数据排队,然后停止过滤器图。
Main thing is that each time you start webcam video you need to do all this: 最主要的是,每次启动网络摄像头视频时,都需要执行以下所有操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.