简体   繁体   中英

Take a Picture of Persenels with a Digital Camera Attached To Computer

I Want Create a Win-Form Application Can be Connect to a Digital Camera Attached to My Computer.I Want See a LiveView of Persenels in Computer And Then Take a Picture of Persenels.

How Can I Implement This Action?

What Camera Can I Use?

What Component Or Library Can I Use??

What SDk Tools Can I Use??

Please Help me...

You can do this with the Windows Image Acquisition API. Get this started with Project + Add Reference, Browse tab, navigate to c:\\windows\\system32\\wiaaut.dll. That's a COM component, you'll get an interop library for it with interface types in the WIA namespace.

First thing you want to do is get a reference to the camera, use WIA.ShowSelectDevice(). It returns a Device object if there's only one camera attached, a dialog to let the user select if there are more. Like this:

    public static WIA.Device SelectCamera() {
        var dlg = new WIA.CommonDialog();
        try {
            return dlg.ShowSelectDevice(WIA.WiaDeviceType.CameraDeviceType, false, false);
        }
        catch (System.Runtime.InteropServices.COMException ex) {
            if (ex.ErrorCode == -2145320939) return null;
            throw;
        }
    }

That ought to get you started. Check out the code snippets at this MSDN page for more of the thing you can do with the API. Beware that not all cameras allow you do use them interactively when they are attached to the machine. My cheapo point-and-shoot doesn't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM