I have a live 16-bit grayscale video stream that is pushed through a ring buffer into memory as a raw, uncompressed stream of bytes (2 bytes per pixel, 2 18 pixels / frames, 32 frames / sec), (This comes from a science-level camera through a PCI grabber). I would like to do some simple processing on the video (dynamic range of clips, colorize, add overlays) and then show it in a window using C #.
This works for me using Windows Forms and GDI (for each frame, create a Bitmap object, write the original 32-bit RGB pixel values ββbased on my post-processing steps, and then draw the frame using the Graphics class). But this uses a significant piece of the processor, which I would like to use for other things. Therefore, I am interested in using WPF for video processing with graphic acceleration. (I would also like to start using WPF to bind and link data.)
But I have never used WPF before, so I donβt know how to approach this. Most of what I find on the Internet about video and WPF involves reading a compressed video file from a disk (such as WMV) or getting a stream from a consumer-grade camera using a driver level that Windows already understands. So it doesn't seem to be applicable here (but correct me if I am wrong about this).
So my questions are:
Is there a WPF-based way to play videos from raw, uncompressed bytes in memory (even if it's an 8-bit gray or 24-bit RGB)?
Do I need to create DirectShow filters (or other DirectShow / Media Foundation-ish stuff) in order to get GPU post processing?
Any general recommendations / suggestions on documentation, examples, blogs, etc. that are relevant to these tasks will also be evaluated. Thanks!
Follow-up observation: After some experiments, I found that WriteableBitmap would be fast enough for my needs and extremely easy to use: just call WritePixels() and any Image controls will be updated to it themselves. InteropBitmap with memory-mapped partitions is noticeably faster, but I had to write p / invokes in kernel32.dll to use it on .NET 3.5.
source share