Question

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

  1. Continuously update the Source of the Image element through a property updated via interop.
  2. Host a custom HWND based control in a HwndHost. The image will be updated when the message pump is idle.
  3. 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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top