views:

24

answers:

1

First of all, my knowledge of C++ is effectively zero. I'm a .NET developer but even my interop experience is minimal.

I have found an example of a control written in C++/CLI that grabs and displays a webcam feed using DirectShow. I'd like to take this example and utilize it from my WPF application. I've tried (and butchered) several different approaches, including taking the Webcam class and creating a HwndHost from my WPF application to load the Webcam control into. I've hit dead ends with all of these things but my understanding of what I'm attempting to achieve isn't enough to form a specific enough question.

So, I'm looking for some guidance on the overall approach I should be taking to achieve this. What do I need to do to expose the C++ webcam component to be consumable by my WPF application? And then what approach should I take to consume that C++ component - Wrapper? PInvoke? Something else?

Here is a link to the VS 2010 solution.

A: 

If you want a Webcam in WPF you can try my WPF MediaKit. It has a VideoCaptureElement you can use and you will not have any airspace issues.

If you want to use your webcam class and use .NET, I would first try getting it to work in a Winforms control. When you have that working, try the WindowsFormsHost control. It will be much easier for you to use vs the raw HwndHost.

Jeremiah Morrill
Thanks for your response. I have been using WPF MediaKit's `VideoCaptureElement` but I've found it to be too slow and lagging for my needs. I wanted to get a better understanding of how it works to produce a much more responsive feed, which is how I've ended up at this point.I'll try and persist with your suggestion to contain it in a Winforms control first. Thanks!
Sio