开发者

Capture image from laptop camera [duplicate]

开发者 https://www.devze.com 2023-03-16 02:23 出处:网络
This question already has answers here:开发者_运维问答 Closed 11 years ago. Possible Duplicate: Control Camera Device From C#
This question already has answers here: 开发者_运维问答 Closed 11 years ago.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号