By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,612 Members | 1,656 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,612 IT Pros & Developers. It's quick & easy.

video capture in Visual C# .NET

P: n/a
Hi,
Im trying to develop a Visual C# .NET app. that uses DirectShow filters to capture video from camera source. However, after going through a series of articles, I've seen that DirectShow is not directly supported in Visual C#.NET.

Im wondering if there's any way to use the video-capture filters of DirectShow in Visual C#.

Otherwise, would it be possible to create a Visual C++ DLL that uses DirectShow filters to capture video from a WDM camera source, and use it in Visual C# .NET program.

Please suggest.

Jul 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Try this

http://www.codeproject.com/dotnet/wi...tingdotnet.asp

I worked for me, although make sure you read the comments at the bottom of
the page, because there was a bug in the source code. I've put the post
about the bug here to save you the trouble....

HTH, John

Correction to sample code DavidDavison 4:20 2 Nov '03

I suggest a correction to the NetMaster's code.

foreach( object wiaObj in wiaDevs )
{
devInfo = (DeviceInfoClass)
Marshal.CreateWrapperOfType( wiaObj, typeof(DeviceInfoClass) );

//Marshal.ReleaseComObject( wiaObj ); <- MOVE THIS

if( devInfo.Type.IndexOf( "Video" ) > 0 )
{
foundID = devInfo.Id;
foundCount++;
}

Marshal.ReleaseComObject( wiaObj ); // <- TO HERE

Marshal.ReleaseComObject( devInfo ); devInfo = null;
}

I have found that the devInfo you have just
marshalled is released before you can use it to check the type.

Other than that, Nice one NetMaster!


"Ravi" <Ra**@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hi,
Im trying to develop a Visual C# .NET app. that uses DirectShow filters
to capture video from camera source. However, after going through a series
of articles, I've seen that DirectShow is not directly supported in Visual
C#.NET.

Im wondering if there's any way to use the video-capture filters of
DirectShow in Visual C#.

Otherwise, would it be possible to create a Visual C++ DLL that uses
DirectShow filters to capture video from a WDM camera source, and use it
in Visual C# .NET program.

Please suggest.



Jul 21 '05 #2

P: n/a

Thank you John. That link is quite useful. Thanks a lot for suggesting the correction to that code too..

"John Young" wrote:
Try this

http://www.codeproject.com/dotnet/wi...tingdotnet.asp

I worked for me, although make sure you read the comments at the bottom of
the page, because there was a bug in the source code. I've put the post
about the bug here to save you the trouble....

HTH, John

Correction to sample code DavidDavison 4:20 2 Nov '03

I suggest a correction to the NetMaster's code.

foreach( object wiaObj in wiaDevs )
{
devInfo = (DeviceInfoClass)
Marshal.CreateWrapperOfType( wiaObj, typeof(DeviceInfoClass) );

//Marshal.ReleaseComObject( wiaObj ); <- MOVE THIS

if( devInfo.Type.IndexOf( "Video" ) > 0 )
{
foundID = devInfo.Id;
foundCount++;
}

Marshal.ReleaseComObject( wiaObj ); // <- TO HERE

Marshal.ReleaseComObject( devInfo ); devInfo = null;
}

I have found that the devInfo you have just
marshalled is released before you can use it to check the type.

Other than that, Nice one NetMaster!


"Ravi" <Ra**@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hi,
Im trying to develop a Visual C# .NET app. that uses DirectShow filters
to capture video from camera source. However, after going through a series
of articles, I've seen that DirectShow is not directly supported in Visual
C#.NET.

Im wondering if there's any way to use the video-capture filters of
DirectShow in Visual C#.

Otherwise, would it be possible to create a Visual C++ DLL that uses
DirectShow filters to capture video from a WDM camera source, and use it
in Visual C# .NET program.

Please suggest

Jul 21 '05 #3

P: n/a
Hey John,
I was trying to use the WIA Device class for video capture, and the correction that you've suggested saved me time. Thank you.

However, the program is not able to detect my Creative Lab webcam and one other USB 2.0 webcam as WIA devices. Its able to detec a hp scanner as a source for images, but, not the webcams.

Is this a limitation of the WIA script, or am I doing something wrong here?

Thanks in advance.
Ravi.

"John Young" wrote:
Try this

http://www.codeproject.com/dotnet/wi...tingdotnet.asp

I worked for me, although make sure you read the comments at the bottom of
the page, because there was a bug in the source code. I've put the post
about the bug here to save you the trouble....

HTH, John

Correction to sample code DavidDavison 4:20 2 Nov '03

I suggest a correction to the NetMaster's code.

foreach( object wiaObj in wiaDevs )
{
devInfo = (DeviceInfoClass)
Marshal.CreateWrapperOfType( wiaObj, typeof(DeviceInfoClass) );

//Marshal.ReleaseComObject( wiaObj ); <- MOVE THIS

if( devInfo.Type.IndexOf( "Video" ) > 0 )
{
foundID = devInfo.Id;
foundCount++;
}

Marshal.ReleaseComObject( wiaObj ); // <- TO HERE

Marshal.ReleaseComObject( devInfo ); devInfo = null;
}

I have found that the devInfo you have just
marshalled is released before you can use it to check the type.

Other than that, Nice one NetMaster!


"Ravi" <Ra**@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hi,
Im trying to develop a Visual C# .NET app. that uses DirectShow filters
to capture video from camera source. However, after going through a series
of articles, I've seen that DirectShow is not directly supported in Visual
C#.NET.

Im wondering if there's any way to use the video-capture filters of
DirectShow in Visual C#.

Otherwise, would it be possible to create a Visual C++ DLL that uses
DirectShow filters to capture video from a WDM camera source, and use it
in Visual C# .NET program.

Please suggest

Jul 21 '05 #4

P: n/a
I honestly could not say because I am a complete beginner to WIA as well.
I do remember somewhere that some camera drivers dont seem to work with WIA.
The only other way would be to use TWAIN, which is on the CodeProject site
as well. Although I haven't tried TWAIN yet.

Good luck, and let the group know how you get on...

HTH

John

"Ravi" <Ra**@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
Hey John,
I was trying to use the WIA Device class for video capture,
and the correction that you've suggested saved me time. Thank you.

However, the program is not able to detect my Creative Lab
webcam and one other USB 2.0 webcam as WIA devices. Its able to detec a hp
scanner as a source for images, but, not the webcams.

Is this a limitation of the WIA script, or am I doing
something wrong here?

Thanks in advance.
Ravi.

"John Young" wrote:
Try this

http://www.codeproject.com/dotnet/wi...tingdotnet.asp

I worked for me, although make sure you read the comments at the bottom
of
the page, because there was a bug in the source code. I've put the post
about the bug here to save you the trouble....

HTH, John

Correction to sample code DavidDavison 4:20 2 Nov '03

I suggest a correction to the NetMaster's code.

foreach( object wiaObj in wiaDevs )
{
devInfo = (DeviceInfoClass)
Marshal.CreateWrapperOfType( wiaObj, typeof(DeviceInfoClass) );

//Marshal.ReleaseComObject( wiaObj ); <- MOVE
THIS

if( devInfo.Type.IndexOf( "Video" ) > 0 )
{
foundID = devInfo.Id;
foundCount++;
}

Marshal.ReleaseComObject( wiaObj ); // <- TO HERE

Marshal.ReleaseComObject( devInfo ); devInfo =
null;
}

I have found that the devInfo you have just
marshalled is released before you can use it to check the type.

Other than that, Nice one NetMaster!


"Ravi" <Ra**@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
> Hi,
> Im trying to develop a Visual C# .NET app. that uses DirectShow
> filters
> to capture video from camera source. However, after going through a
> series
> of articles, I've seen that DirectShow is not directly supported in
> Visual
> C#.NET.
>
> Im wondering if there's any way to use the video-capture filters of
> DirectShow in Visual C#.
>
> Otherwise, would it be possible to create a Visual C++ DLL that uses
> DirectShow filters to capture video from a WDM camera source, and use
> it
> in Visual C# .NET program.
>
> Please suggest

Jul 21 '05 #5

P: n/a
John,

I was wondering if you tried to use this code in a batch program? The
supplied code requires a user to be present to click the capture button, I
want to put something on a schedule and run unattended.

Thanks

"John Young" wrote:
Try this

http://www.codeproject.com/dotnet/wi...tingdotnet.asp

I worked for me, although make sure you read the comments at the bottom of
the page, because there was a bug in the source code. I've put the post
about the bug here to save you the trouble....

HTH, John

Correction to sample code DavidDavison 4:20 2 Nov '03

I suggest a correction to the NetMaster's code.

foreach( object wiaObj in wiaDevs )
{
devInfo = (DeviceInfoClass)
Marshal.CreateWrapperOfType( wiaObj, typeof(DeviceInfoClass) );

//Marshal.ReleaseComObject( wiaObj ); <- MOVE THIS

if( devInfo.Type.IndexOf( "Video" ) > 0 )
{
foundID = devInfo.Id;
foundCount++;
}

Marshal.ReleaseComObject( wiaObj ); // <- TO HERE

Marshal.ReleaseComObject( devInfo ); devInfo = null;
}

I have found that the devInfo you have just
marshalled is released before you can use it to check the type.

Other than that, Nice one NetMaster!


"Ravi" <Ra**@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hi,
Im trying to develop a Visual C# .NET app. that uses DirectShow filters
to capture video from camera source. However, after going through a series
of articles, I've seen that DirectShow is not directly supported in Visual
C#.NET.

Im wondering if there's any way to use the video-capture filters of
DirectShow in Visual C#.

Otherwise, would it be possible to create a Visual C++ DLL that uses
DirectShow filters to capture video from a WDM camera source, and use it
in Visual C# .NET program.

Please suggest

Jul 21 '05 #6

P: n/a
rod
your on the right track. directshownet works well, but you may want to try
the
directx.capture from the same site, it's an update from someone else.
but it can give you more control.

"Ravi" wrote:
Thank you for the prompt reply John.

Im trying to use one other wrapper class from the same site, i.e., code project.
Its the DirectShow.NET class and is quite similar to WIA class.

http://www.codeproject.com/cs/media/directshownet.asp

Its working fine for the web-cams. Now, Im trying to combine the features of image-grabbing, saving-to-file and file-playback into one program.

"John Young" wrote:
I honestly could not say because I am a complete beginner to WIA as well.
I do remember somewhere that some camera drivers dont seem to work with WIA.
The only other way would be to use TWAIN, which is on the CodeProject site
as well. Although I haven't tried TWAIN yet.

Good luck, and let the group know how you get on...

HTH

John

"Ravi" <Ra**@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
Hey John,
I was trying to use the WIA Device class for video capture,
and the correction that you've suggested saved me time. Thank you.

However, the program is not able to detect my Creative Lab
webcam and one other USB 2.0 webcam as WIA devices. Its able to detec a hp
scanner as a source for images, but, not the webcams.

Is this a limitation of the WIA script, or am I doing
something wrong here?

Thanks in advance.
Ravi.

"John Young" wrote:

> Try this
>
> http://www.codeproject.com/dotnet/wi...tingdotnet.asp
>
> I worked for me, although make sure you read the comments at the bottom
> of
> the page, because there was a bug in the source code. I've put the post
> about the bug here to save you the trouble....
>
> HTH, John
>
> Correction to sample code DavidDavison 4:20 2 Nov '03
>
> I suggest a correction to the NetMaster's code.
>
> foreach( object wiaObj in wiaDevs )
> {
> devInfo = (DeviceInfoClass)
> Marshal.CreateWrapperOfType( wiaObj, typeof(DeviceInfoClass) );
>
> //Marshal.ReleaseComObject( wiaObj ); <- MOVE
> THIS
>
> if( devInfo.Type.IndexOf( "Video" ) > 0 )
> {
> foundID = devInfo.Id;
> foundCount++;
> }
>
> Marshal.ReleaseComObject( wiaObj ); // <- TO HERE
>
> Marshal.ReleaseComObject( devInfo ); devInfo =
> null;
> }
>
> I have found that the devInfo you have just
> marshalled is released before you can use it to check the type.
>
> Other than that, Nice one NetMaster!
>
>
>
>
>
>
> "Ravi" <Ra**@discussions.microsoft.com> wrote in message
> news:70**********************************@microsof t.com...
> > Hi,
> > Im trying to develop a Visual C# .NET app. that uses DirectShow
> > filters
> > to capture video from camera source. However, after going through a
> > series
> > of articles, I've seen that DirectShow is not directly supported in
> > Visual
> > C#.NET.
> >
> > Im wondering if there's any way to use the video-capture filters of
> > DirectShow in Visual C#.
> >
> > Otherwise, would it be possible to create a Visual C++ DLL that uses
> > DirectShow filters to capture video from a WDM camera source, and use
> > it
> > in Visual C# .NET program.
> >
> > Please suggest


Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.