1

Possible Duplicate:
Control Camera Device From C#

I have a laptop that has a built in camera in the lid.

I want to write a C# application to capture the image, and save it to the hard drive.

Does anyone have a quick code snippet to accomplish this?

I am running under windows 7 (64bit)

Community
  • 1
  • 1
pithhelmet
  • 1,969
  • 5
  • 28
  • 54

2 Answers2

5

The Emgu cv library is overkill for this, but here is an example in 7 lines:

ImageViewer viewer = new ImageViewer(); //create an image viewer
Capture capture = new Capture(); //create a camera captue
Application.Idle += new EventHandler(delegate(object sender, EventArgs e)
{  //run this until application closed (close button click on image viewer)
   viewer.Image = capture.QueryFrame(); //draw the image obtained from camera
});
viewer.ShowDialog(); //show the image viewer

(source: http://emgu.com/wiki/index.php/Camera_Capture_in_7_lines_of_code)

jonsca
  • 9,342
  • 26
  • 53
  • 60
DallinDyer
  • 1,318
  • 13
  • 14
  • In my case in MS WIndows 10 I see only black screen instead of video stream via this framework but for instance? Skype video settings showing video well. So This platform is not good solution. – DmitryBoyko Jan 22 '18 at 02:04
1

Let me point you towards the DirectShow library.

http://directshownet.sourceforge.net/about.html

Find an appropriate sample that runs, then inspect the source code.


Here's another link that you may find helpful: C# + DirectShow.NET = Simple WebCam access?

Community
  • 1
  • 1
jglouie
  • 11,300
  • 5
  • 41
  • 64