How do you superimpose text, a still image, or windows.drawing graphics over a video stream?
I am using a third-party .NET video capture function library that 开发者_StackOverflowdisplays 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
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.
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.
精彩评论