laitimes

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

In the previous project, do the camera picture collection, we generally still need to do a package processing, in the newer version of the DevExpress control, added a CameraControl control, you can directly call the camera display, so you can also do avatar acquisition and other functions, this article describes how to do related image acquisition operations based on this control.

DevExpress WinForms Subscription Official Latest Edition Free Download Trial, Historical Version Download, Online Documentation and Help File Download - Huidu.com

<h1 class="pgc-h-arrow-right" data-track="3" >, CameraControl control introduction</h1>

The control from 15.1 onwards, began to join the control group, the use of the control is very simple, directly drag to the interface can be used on the WinForm interface. This case is based on 16.1 and therefore also has these control modules.

For example, we can directly drag the CameraControl control to the interface, and then run the interface to see the following effect.

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

On the camera interface, there is a configuration option that can be set to process parameters such as the resolution of the camera.

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

At the same time, on the PictureEdit control, you can also turn on the camera acquisition function, just need to set it in the control properties:

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

The effect of running the interface is as follows.

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

The text of this menu item for collecting images is not Chinese, so it is a bit weird, and we can also do image collection by using its built-in dialog (TakePictureDialog).

The specific code is as follows:

The dialog box resulting from the call is built-in, and the interface cannot be modified to adjust, including text content.

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

<h1 class="pgc-h-arrow-right" data-track="13" >2. Customize the acquisition dialog</h1>

In order to better realize the acquisition operation of the avatar, we can imitate this dialog module and make a custom form to implement the acquisition operation of the camera image, as shown below.

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

At the same time, we set a Public image object property in the dialog form as follows:

This makes it easy to set up and extract image information.

The code to capture the image is to take a snapshot from inside the camera control, as shown below.

Then when the form exits, remember to release the resources of the camera, otherwise it will prompt for occupation for the second time and cannot be used.

The complete code for the entire dialog box is shown below.

The last run can get the interface as shown below.

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

This kind of processing is better, before the control came out, in the basic interface class library, I used the portrait control to process the camera image acquisition.

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

For example, in the membership management system, it is the use of portrait management controls to achieve graphic acquisition operations through the previous camera common class library.

Did you know that DevExpress controls can do camera image acquisition? First, The CameraControl control introduction two, custom collection dialog

This is actually implemented using a camera library, but now that DevExpress itself provides control support, we can also take advantage of it directly, which is more convenient and less code.

DevExpress WinForm controls | Download the trial

With 180+ components and UI libraries, DevExpress WinForm creates impactful business solutions for the Windows Forms platform. DevExpress WinForms is perfect for building smooth, beautiful, and easy-to-use applications, whether it's an Office-style interface or analyzing and processing large amounts of business data.

This article is reproduced from: Blog Garden - Wu Huacong