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!
Ideas
- Continuously update the
Source
of the Image element through a property updated via interop. - Host a custom
HWND
based control in a HwndHost. The image will be updated when the message pump is idle. - Write a source filter in DirectShow that, using some kind of timing logic, reads the buffer continuously - making it possible to show the live view using MediaElement.
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
?