473,382 Members | 1,247 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

video capture in Visual C# .NET

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
6 18540
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

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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Juan Crespo | last post by:
Dear Sirs: My name is Juan Crespo and I write you from Spain, I work as application developer in Industrial Automation in Spain. We have as customer a company that wants to reuse old computers...
1
by: Omar Hamido | last post by:
How i can do video capture with c#...more especific, i have a video capture card pci and my question is: if possible to do that... regards... Omar
1
by: Ravi | last post by:
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...
2
by: Arash | last post by:
Dear all, I've got a video capture device. Device manager shows "nVidia WDM Video Capture (universal)" driver in "Sound, video and game controllers" category. Also, Windows Movie Maker, and...
4
by: ABC | last post by:
I. I have a video capture project, like AmCap, written in VB.NET. It is a windows applications. Is it possible to put it into a web page? II. Is the conversion in I complicated? Involve ActiveX...
2
by: John | last post by:
Hi, Could anyone point me in the right direction for using video capture? I'd like to write a basic VB.NET app that shows the output from a composite camera and has a simple record now button. ...
6
by: Ravi | last post by:
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...
0
by: peridian | last post by:
Hi, I want to get a video capture card for my PC, which runs both WinXP Pro SP3 and Vista Business SP1. Nearly all the video capture cards I see state they only run on Windows Media Centre...
1
by: David Hood | last post by:
Hello, I made a program to capture photos from 3 web cams (with video capture). With one or two cams, the program works perfectly. With 3 cams, my program doesn't work. The third window...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.