嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
	using AForge.Video.DirectShow;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _调用USB摄像头
{
    public partial class Form1 : Form
    {
        private FilterInfoCollection videoDevices;//所有摄像设备
        private VideoCaptureDevice videoDevice;//摄像设备
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);//得到所有接入的摄像设备
            if (videoDevices.Count != 0)
            {
                foreach (FilterInfo device in videoDevices)
                {
                    comboBox1.Items.Add(device.Name);//把摄像设备添加到摄像列表中                    
                }
            }
            else
            {
                MessageBox.Show("没有找到摄像头!");
            }
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            videoDevice = new VideoCaptureDevice(videoDevices[comboBox1.SelectedIndex].MonikerString);
            videoSourcePlayer1.VideoSource = videoDevice;
            videoSourcePlayer1.SignalToStop();//使用方法等待视频源停止。
            videoSourcePlayer1.WaitForStop();//等待视频源停止或暂停
        }
        private void uiButton1_Click(object sender, EventArgs e)
        {
            videoSourcePlayer1.Start();//开始
        }
        private void uiButton2_Click(object sender, EventArgs e)
        {
            videoSourcePlayer1.Stop();//暂停
        }
    }
}