I have a hi-resolution camera connected via firewire. An SDK lets me grab frames into a byte buffer. E.g.:
unsigned char *buffer = new unsigned char[size];
GetFrameBuffer(cameraHandle, buffer);
Due to the nature of the API, frames need to be grabbed continuously (20+ fps) to show a live view. Now, I want to display this in my WPF UI. I can think of several approaches, but I need help determine which method to choose!
Source
of the Image element through a property updated via interop.HWND
based control in a HwndHost. The image will be updated when the message pump is idle.Obviously, I want to minimize the CPU load.
The question boils down to this:
In WPF, how do I show a live stream from a firewire connection with primitive APIs like GetFrameBuffer
?
I think the easiest way is the first one. Just update the image source. If you just want to display it, you don't need a directshow filter for this. But if you also want to capture it, the DirectShow filter is the best way!
Updating the image-source is an easy task. A good example for this is the Mjpeg decoder for .net. You just need to replace the Mjpeg reader/parser with your own grabber logic.