C# get camera data by referencing AForge

I. Overview

    The camera data can be read, and when multiple camera devices are connected to the computer, the connected camera device can be selected. The camera data is displayed in real time, and it has the function of taking screenshots (photographs), which can be saved for subsequent image processing.

Second, the window effect


Three, steps

(1) First, use the AForge library download address: http://www.aforgenet.com/

(2) Copy the "Release" folder in the downloaded class library to the executable file folder (Debug folder) of the C# project


(3) Add references in the C# project

Put the cursor on the "Reference" under "Solution Explorer", click the right mouse button, and click Add Reference


Click "Browse", find the "Release" folder under the Debug folder, and add several files as shown in the figure above

(4) Add AForge.Controls control in the toolbox

First add a new tab in the toolbox (right-click) and name it Camera; then drag the AForge.Controls.dll file in the Release folder to Camera, and Camera will add a new control. The effect is as shown below:


(5) Place a videoSourcePlayer control in the form, because the camera data is displayed;

(6) Place 3 button controls Button in the form, namely "Connect camera", "Close camera", and "Take a picture (screenshot)";

(7) Place a Label on the form, and set the Text property of the Label control to "Select Video Input Device"; also place a comboBox control on the form to select the name of the video input device and display device.

Four, C# code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using AForge;
using AForge.Controls;
using AForge.Imaging;
using AForge.Video;
using AForge.Video.DirectShow;

using System.Drawing.Imaging;

。。。。。。




      
 



 



Guess you like

Origin blog.csdn.net/zwb_578209160/article/details/80309377