如何在视频流上叠加文本、静态图像或 windows.drawing 图形?

发布于 2024-09-08 17:40:32 字数 344 浏览 4 评论 0原文

我正在使用第三方 .NET 视频捕获函数库,该库在 VideoPictureBox 中显示来自 USB 视频捕获设备的流视频(这与通常的 .NET PictureBox 非常相似)。我想通过视频流显示图形和文本。

是否有某种方法可以叠加常规 PictureBox,使图形和文本出现在视频之上?看起来应该可以创建一个透明的 PictureBox,显示其下方的所有内容,但允许 windows.drawing 图形和文本以通常的方式写入 PictureBox 中......就像使用魔术笔在窗玻璃。

一个人会怎样写这篇文章呢?我通常使用 VB.NET,但 C# 也可以(Visual Studio 2005)。

——戴夫·埃默里

I am using a third-party .NET video capture function library that displays atreaming video from a USB video capture device in a VideoPictureBox (which is very much like the usual .NET PictureBox). I want to display graphics and text over the video stream.

Is there some way to superimpose a regular PictureBox such that the graphics and text will appear on top of the video? It would seem that it should be possible to create a transparent PictureBox that shows whatever is underneath it, but allowing windows.drawing graphics and text to be written in the PictureBox in the usual manner... like using a magic marker to wiite on a window pane.

How would one go about writing this? I usually use VB.NET but C# is OK also (Visual Studio 2005).

--Dave Emery

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你丑哭了我 2024-09-15 17:40:32

您可能需要查看 Windows Presentation Foundation 中的此应用程序。 Winforms 控件确实支持透明背景,但实际上它们只是通过拍摄下面的图片来支持。在某些情况下(我认为您的移动视频很可能就是其中之一),这种技术效果不太好。另一方面,WPF 应该能够很好地处理这个问题。

You may want to look at Windows Presentation Foundation for this app. Winforms controls do have support for transparent backgrounds, but really they only fake that support by taking a picture of what's underneath. In certain situations (and I think your moving video is likely to be one of these) this technique just doesn't work that well. WPF, on the other hand, should be able to handle this just fine.

逆夏时光 2024-09-15 17:40:32

你没有说,但我假设视频是用 DirectShow 渲染的。在这种情况下,您可以使用 WPF 渲染它(如上所述),或者将您自己的过滤器注入 DirectShow FilterGraph。您可以制作一个过滤器,用于点击视频流并将其呈现在您自己的自定义控件中,或者在呈现之前更改视频内容。

但在执行所有这些操作之前,值得尝试一下 VideoPictureBox 是否能与 WinForm 的双缓冲渲染配合良好。可能不会,但如果幸运的话,工作量会少很多。

You don't say, but I am assuming that the video is rendered with DirectShow. In that case, you could render it with WPF (as suggested above), or inject your own filter to the DirectShow FilterGraph. You could make a filter that taps the video stream and renders it in a custom control of your own, or change the video content before it's rendered.

But before you do all this, it's worth trying if the VideoPictureBox works nice together with WinForm's double buffered rendering. Probably won't but a lot less work if you're lucky.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文