Is Video Capture available in .NET platform?

  • Thread starter Thread starter Lio
  • Start date Start date
L

Lio

Hello,

I used to write video capture applications in MFC, now with the new .NET
platform i was trying to find the way to do it in C# but could not find the
libraries for video capturing.
does it exsist in .NET???

thanks

Lio
 
The current DirectX 9.0(b) for .NET only provides
simple media playback.
There is no support for video (frame) capturing.

Microsoft recommends to use classic C++/COM for more on DirectShow.

If you really want to use DirectShow with .NET:

- you can write wrappers with 'Managed C++ .NET'
http://msdn.microsoft.com/library/en-us/dncscol/html/csharp12192002.asp
http://sunlightd.virtualave.net/Windows/DirectX.NET/

- or write (heavy) COM-Interop code like:
http://www.codeproject.com/cs/media/directshownet.asp

http://www.codeproject.com/cs/media/DirectXCapture.asp
 
Hi Thomas,

I have a complete project written in C# and I would like to add Video
Capture functionality to it. I have a complete video capture application
written in C++ and uses the famiy of capCreateCaptureWindow functions which
are unmanaged. So, I wrote a Managed C++ class and i tried to use these
function in #pragma unmanaged - but it is not working. do i have to wrap the
all vfw.h for this reason? how can i mix the code??? i understood that it is
possible to mix unmanaged and managed code to the same DLL that will be
exposed to C# and the whole .NET platform.

thanks

Lio
 
Hi again Thomas

Yes, I read the first one and did not find the answer, I read today the
second one... it helped...

Thank you very much !!!

Lio
 
Thomas, Hi again...

I would like to give you example of my code. I wrote a simple DLL that
works, I have defined, for example (in my unmanaged C++ DLL):

EXAMPLE NO. 1

extern "C" __declspec(dllexport) BOOL CapPreview(HWND hwnd, bool f)
{
return capPreview(hwnd, f); //belongs to the included Vfw.h
}

and from C# i called the DLL function like that:

[DllImport("VidCapDll.dll")]
public static extern bool CapPreview(int hwnd, bool f);

It works !!! and with the other Video Capture functions I am able to capture
video from C#.

Then, I have decided to follow your article and to create a Managed C++ DLL
and to wrap with it an unmanaged C++ Class, for example:

EXAMPLE NO. 2

in the unmanaged class:

class UMClass
{
public:
BOOL CapPreview(HWND hwnd, bool f) {return capPreview (hwnd, f);}
}

in the managed class:
class MClass
{
public:
bool MCapPreview(int hwnd, bool f) { return m_pUMC->CapPreview(hwnd,
f); }
private:

UMClass * m_pUMC;
}

Now, in this case I get a convertion error, the compiler cannot convert the
parameter from INT to HWND (in the first example there was no problem to
send INT from C# to the HWND in the unmanaged DLL).

How can I solve it???

Thanks again

Lio
 
Hi Thomas

I tried something like that.
the problem is that HWND that you wrote in your cast: return
m_pUMC->CapPreview( (HWND) hwnd.ToPointer(), f ); is then, appear in the
member function of the Managed class, but it is not recognized in the
managed class even when i include the libraries.
do you have any suggestions?

thanks again

Lio
 
Back
Top