单个应用程序中的多个图形 [英] Multiple Graphs in a Single Application

查看:58
本文介绍了单个应用程序中的多个图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

所以,我试着在论坛上搜索答案,但我一直收到一个空白的结果屏幕,所以请原谅我以前的答案。

So, I tried searching the forum for an answer, but I keep getting a blank results screen, so forgive me if this has been previously answered.

我是DirectShow的新手,但我已经能够成功创建一个过滤器图形,预览视频并将其捕获到VB.NET中的.avi文件中。

I'm very new to DirectShow, but I have been able to successfully create a filter graph that previews video and captures it to an .avi file in VB.NET.

如果我希望录音是有条件的(开始和结束某些事件),我知道我必须停止图表,添加(或删除)ASF Writer过滤器到图表,然后重新启动图表。 显然,这个过程也会停止我的视频
预览一两秒。

If I want the recording to be conditional (beginning and ending on some event(s)), I understand that I have to stop the graph, add (or remove) the ASF Writer filter to the graph, and restart the graph.  Obviously, this process also stops my video preview for a second or two.

我在另一个论坛中读到了一个关于为预览和捕获创建单独图形的建议,以防止这种情况发生。挂起,但我没有成功。

I read a suggestion in another forum about creating separate graphs for previewing and capturing in order to prevent this hang, but I have been unsuccessful in doing this.

在进入任何代码细节之前,有人可以验证我的算法,看看我正在做什么是允许的吗?

Before getting into any code specifics, can someone verify my algorithm to see if what I'm doing is permissible?

首先,我有两个类 - 一个Preview类和一个Capture类,两者都(可能)创建了自己的过滤器图形对象。 这就是我正在做的事情:

First of all, I have two classes -- a Preview class and a Capture class, both of which (presumably) create their own filter graph objects.  Here's what I'm doing:

1) 从客户端应用程序中,枚举视频捕获设备(网络摄像头)并将发现的设备绑定到对象。  (来源)

2) 将对象转换为IBaseFilter接口类型。  captureDevice = CType(source,IBaseFilter)

3) 实例化Preview类的实例,将引用传递给captureDevice接口。

4) 在预览对象中,使用此引用将过滤器添加到图形中 - 连接引脚,运行图形。

5) 实例化Capture类的实例,将相同的引用传递给captureDevice接口。

6) 在Capture对象中,使用此引用将过滤器添加到图形中 - 连接引脚,运行图形。

1)  From the client application, enumerate the video capture devices (webcams) and bind the discovered device to an object.  (source)
2)  Cast the object to the IBaseFilter interface type.  captureDevice = CType(source, IBaseFilter)
3)  Instantiate an instance of the Preview class, passing the reference to the captureDevice interface.
4)  In the Preview object, add the filter to the graph using this reference -- connect the pins, run the graph.
5)  Instantiate an instance of the Capture class, passing the same reference to the captureDevice interface.
6)  In the Capture object, add the filter to the graph using this reference -- connect the pins, run the graph.

预览部分正常工作。 但是,当实例化Capture对象时,当我尝试运行图形时会发生异常。 它告诉我它无法对不在过滤器图形中的对象执行所请求的功能。 但是,当我将过滤器添加到图表中时,
我没有得到异常。

The preview portion works fine.  However, when the Capture object is instantiated, the exception occurs when I try to run the graph.  It tells me that it can't perform the requested function on an object that is not in the filter graph.  However, I'm not getting an exception when I add the filter to the graph.

正如我所写的那样,任何人都可以对可能存在的内容有所了解继续?

Just from what I've written, can anyone shed any light on what might be going on?

谢谢。

推荐答案

如果你添加相同的捕获,什么都不应该出错设备到两个图,但你不能同时运行它们。你的代码可以创建你想要它的所有对象,但它无法实例化物理相机。

Nothing should go wrong if you add the same capture device to two graphs, but you won't be able to run them both at the same time. Your code can create all the objects you want it to, but it can't instantiate physical cameras.

我使用tee过滤器快速处理预览开启和关闭其中一个输出,以及来自另一个输出的捕获代码,根据需要使预览窗口可见(或不显示)。但是,图表一直在运行
技巧。这听起来不适合你,但我对ASF作家的了解甚少。为什么必须从图表中删除它才能使录制成为有条件的?你可以在发球台输出的一侧用自定义过滤器喂它吗,你可以根据需要命令丢弃/传递帧吗?

I handle speedily turning preview on and off with a tee filter that feeds my preview window from one of its outputs, and my capture code from another output, making the preview window visible (or not) as needed. But, the graph runs all the time with that trick. Sounds like that won't work for you, but I know little yet of the ASF Writer. Why does it have to be removed from your graph to make your recording conditional? Could you feed it with a custom filter on one side of a tee's output, one that you could command to drop/pass frames as you need it to?


这篇关于单个应用程序中的多个图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆