Take a picture from the built-in camera for laptops using C #

I am trying to write one part of my huge C # program, which allows me to capture one image from an integrated camera in a laptop. I have already done my research, and I noticed that there are two ways to do this through WIA and DirectShow. I'm trying to make it simpler: WIA. I am working on a 32-bit Windows 7 machine running on VS 2010.Net 4.0. I am trying to run the following example that I found on the Internet, and that is exactly what I want, and experienced several errors regarding it.

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

I added the necessary link

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

Most errors look like this: Interop type 'WIA.CommonDialogClass' cannot be inlined. Use the appropriate interface instead. Interop type 'WIA.CommandID' cannot be embedded. Use the appropriate interface instead.

Any help provided would be very helpful.

+4
source share
2 answers

Try the following:

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

The creation of COM interfaces with the new operator is allowed. You need to specify a namespace name, since CommonDialog is ambiguous with the Winforms CommonDialog class.

+1
source

I found a solution that just satisfies my needs without going through DirectShow. This is done using the avicap32.dll library. Those who want to implement something similar to mine. You can take a look at this link http://www.timvw.be/wp-content/code/csharp/testavicap32.zip . just compile it with VS 2010, it works. Just study, understand and customize the example to suit your needs.

+2
source

Source: https://habr.com/ru/post/1340262/


All Articles