473,396 Members | 1,995 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,396 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 18543
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.