开发者

Take a picture from Integrated Laptop Camera using C#

I am trying to write one portion of my huge C# program that allows me to capture one picture from the integrate camera in the laptop. I have already done my research and i notice that there are 2 ways开发者_StackOverflow中文版 to do this via WIA and DirectShow. I am trying the easier one : WIA. I am working on a Windows 7 32 bit machine running VS 2010 .Net 4.0 . I am trying to run the following example i found on the web, which is exactly what i want and experienced several errors with regards to it.

http://www.c-sharpcorner.com/uploadfile/yougerthen/610262008064756am/6.aspx

I have added the necessary reference


using System.Windows.Forms;
using Microsoft.Win32;
using WIA;

Majority of the errors are like the following : Interop type 'WIA.CommonDialogClass' cannot be embedded. Use the applicable interface instead. Interop type 'WIA.CommandID' cannot be embedded. Use the applicable interface instead.

Any help provided will be greatly appericiated.


I found a solution that just suite my needs without going through DirectShow. It is done using the avicap32.dll library. Those who want to implement something similar as mine. Can have a look at this link http://www.timvw.be/wp-content/code/csharp/testavicap32.zip . just compile it with VS 2010, it works. Just learn, understand and tweak the example to suite to your needs.


Try this:

WIA.CommonDialog wiaDiag = new WIA.CommonDialog();

Creating COM interfaces with the new operator is allowed. You need to prefix the namespace name because CommonDialog is ambiguous with the Winforms CommonDialog class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜