6

I have found an example for accessing a webcam in C#. The example uses the DirectShow.NET library. I have tried to understand the code, but so far the only thing I could figure out is that somehow the usercontrol calls directshow to draw directly to the surface of the user control.

I want to access each frame and put it into a Bitmap object. How can I tell when a new frame arrived? How can I capture this new frame into a Bitmap Object?

This might be simple to answer if you know your way around DirectShow.NET.

itsho
  • 4,111
  • 3
  • 37
  • 61
George
  • 14,181
  • 20
  • 63
  • 81

3 Answers3

6

You will need to use the ISampleGrabber interface there are many c++ examples on the net on how to use it, it will give you data the in RGB raw format which you can feed into the Bitmap class.

There is also an open source library called Touchless it has a project in code which takes a web cam and give you a callback every time a new frame arrived.

reinierpost
  • 7,591
  • 1
  • 32
  • 66
Shay Erlichmen
  • 31,099
  • 7
  • 64
  • 86
  • Can you tell me where can I get the qedit.h needed for compiling touchless' WebCamLib? I have downloaded both the windows sdk and the directx sdk, but could not find it anywhere. – George May 07 '09 at 11:30
  • 2
    know issue, you need the an old August 2007 DirectX SDK. http://www.microsoft.com/downloads/details.aspx?familyid=529F03BE-1339-48C4-BD5A-8506E5ACF571&displaylang=en – Shay Erlichmen May 07 '09 at 11:36
  • I have installed the August 2007 SDK, but havn't found the qedit.h in the include dir or anywere else. – George May 07 '09 at 13:15
  • My experience on compiling the WebCamLib: you need to download a ~222M file "dx9sdk.exe", its a very old directx 9 sdk (2002), a google search for the filename will help you. After the install in the include dir, you will find the qedit.h. You have to specify this directory in the project properties of WebCamLib. Make sure to compile it in Release, or Vista will cry. Also you might get and error and have to change a POINTER_64 constant to __ptr64. – George May 07 '09 at 15:02
  • Success! Thanks, Touchless was great help :) – George May 07 '09 at 16:58
  • @Shay Erlichmen: the _ISampleGrabber_ API "may be removed from future releases of Windows". see on the link you have provided... – itsho Aug 22 '12 at 20:38
  • @itsho well on metro apps it is no longer supported – Shay Erlichmen Aug 22 '12 at 21:26
4

Be sure to take a look at this article - http://www.codeproject.com/Articles/125478/Versatile-WebCam-C-library ; it is based on Touchless WebCam capturing component (but without other parts from Touchless SDK).

nikib3ro
  • 19,427
  • 21
  • 113
  • 173
0

If you found Touchless useful, but would like to use the latest DirectX SDK, try getting the latest source after change 31008 at http://touchless.codeplex.com/SourceControl/ListDownloadableCommits.aspx