Render to Video Input/Output cards (e.g. BlackMagic Design's Decklink) as a Window in .NET
I am investigating the possibility of treating a video input/output card as a Window so that I can render graphics to it from .NET. It would need the ability to handle transparency so that I can key the rendered开发者_如何学Go graphics over incoming video.
I haven't found anything that does exactly this - some SDKs allow you to render graphics, but you have to use their API to draw them, rather than using standard .NET WPF/Windows Forms routines.
I use the decklink cards with C# and do something similar to what you are looking to do. I use the standard Graphics object (GDI+) that I created using Graphics.FromImage(). At each frame completed callback I draw on the graphics object and then get a pointer to the connected bitmap and copy the pixels to the decklink video frame buffer. In the copy you can do whatever you want with the transparent pixels (not copy and leave the input there instead etc..) Essentially all you need is a pointer to an ARGB surface (or whatever format you're set up for) and you can copy it to the decklinks frame buffer.
Although I do not use a video input with it (I am keying over a still image sequence), looking at the API it does not look difficult to copy the input frame and then draw your objects on top of it and then copy it to the output buffer. There are some samples in the SDK (mostly in native code but it's easy to see what is going on) and they provide an interop dll which makes access to the API from .net easy.
There is a black-magic developers mailing list you should check out also.
Brian
精彩评论