Capture image from laptop camera [duplicate]
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)
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)
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?
精彩评论