基本信息
源码名称:打开usb摄像头 并实现抓拍操作
源码大小:0.26M
文件格式:.rar
开发语言:C#
更新时间:2020-06-17
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

打开电脑摄像头或者外接usb摄像头

 public partial class MainForm : Form
    {
        private USBCamera uc = null;
        private bool m_bPlay = false;


        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            this.uc = new USBCamera();
        }

        private void buttonPlay_Click(object sender, EventArgs e)
        {
            this.uc.RealPlay(this.pictureBoxPlay.Handle);
            this.m_bPlay = true;
        }

        private void buttonSnap_Click(object sender, EventArgs e)
        {
            if (m_bPlay == false)
            {
                MessageBox.Show("请先打开视频!");
                return;
            }
            Image objImage = this.uc.CapturePicture();
            this.pictureBoxImage.Image = this.uc.CapturePicture();

            SaveFileDialog sfdlg = new SaveFileDialog();
            sfdlg.Filter = "*.jpg|*.png";
            if (sfdlg.ShowDialog() == DialogResult.OK)
            {
                objImage.Save(sfdlg.FileName);
            }
        }

        private void buttonStopPlay_Click(object sender, EventArgs e)
        {
            this.uc.StopRealPlay();
            this.m_bPlay = false;
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.uc.StopRealPlay();
            this.m_bPlay = false;
        }

        private void buttonStart_Click(object sender, EventArgs e)
        {
            this.timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (m_bPlay == false)
            {
                return;
            }

            string strPath = Application.StartupPath;
            Image objImage = this.uc.CapturePicture();

            objImage.Save(strPath "\\" DateTime.Now.ToString("yyyyMMddHHmmss") ".jpg");
        }

        private void buttonStop_Click(object sender, EventArgs e)
        {
            this.timer1.Stop();
        }
    }