• 大小: 239KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: C#
  • 标签: c#  摄像头  截屏  

资源简介

真正能用 c# 摄像头 控制 截屏 拍照 等 代码 ,本人亲测可以用,不会报错。基本的功能都有

资源截图

代码片段和文件信息

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


namespace Camera
{
    public partial class Camera : Form
    {
        WebCamera camera;
        DeviceCapabilityInfo _DeviceCapabilityInfo;
        DeviceInfo _DeviceInfo;
        public Camera()
        {
            

            InitializeComponent();
            camera = new WebCamera();
            foreach (DeviceInfo info in camera.GetCameras())
            {
                comboBox1.Items.Add(info);
            }
            camera.NewframeEvent += new NewframeEventHandler(camera_NewframeEvent);
        }

        void camera_NewframeEvent(object sender EventArgs e)
        {
           pictureBox1.Image = camera.Newframe;
        }

       

        private void comboBox1_SelectedIndexChanged(object sender EventArgs e)
        {
            comboBox2.Items.Clear();
            _DeviceCapabilityInfo = null;
            _DeviceInfo=(DeviceInfo)comboBox1.SelectedItem;
            foreach (DeviceCapabilityInfo info in camera.GetDeviceCapability(_DeviceInfo))
            {
                comboBox2.Items.Add(info);
            }
        }

        private void comboBox2_SelectedIndexChanged(object sender EventArgs e)
        {
            _DeviceCapabilityInfo = (DeviceCapabilityInfo)comboBox2.SelectedItem;
        }

        private void button1_Click(object sender EventArgs e)
        {
            if (_DeviceInfo != null && _DeviceCapabilityInfo != null)
            {
                if (camera.StartVideo(_DeviceInfo _DeviceCapabilityInfo))
                    button2.Enabled = true;
            }
        }

        private void button3_Click(object sender EventArgs e)
        {
            if (camera.DeviceExist)
            {
                if (camera.CloseVideo())
                    button2.Enabled = false;
            }
        }

        private void button2_Click(object sender EventArgs e)
        {
            pictureBox2.Image = camera.Newframe;
        }

        private void Camera_FormClosed(object sender FormClosedEventArgs e)
        {
            if (camera.DeviceExist)
                camera.CloseVideo();
            this.Dispose();
        }
       
       
    }

   
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    I.A....     17408  2012-02-23 20:13  Camera\Camera\Aforge\AForge.dll

    I.A....     57856  2012-02-28 20:50  Camera\Camera\Aforge\AForge.Video.DirectShow.dll

    I.A....     18944  2012-02-23 20:13  Camera\Camera\Aforge\AForge.Video.dll

     文件      44544  2012-02-23 20:13  Camera\Camera\bin\Debug\AForge.Controls.dll

     文件      17408  2012-02-23 20:13  Camera\Camera\bin\Debug\AForge.dll

     文件      57856  2012-02-28 20:50  Camera\Camera\bin\Debug\AForge.Video.DirectShow.dll

     文件      18944  2012-02-23 20:13  Camera\Camera\bin\Debug\AForge.Video.dll

     文件      14848  2012-09-16 18:32  Camera\Camera\bin\Debug\Camera.exe

     文件      46592  2012-09-16 18:32  Camera\Camera\bin\Debug\Camera.pdb

     文件      11608  2012-09-16 18:32  Camera\Camera\bin\Debug\Camera.vshost.exe

     文件      14336  2008-10-12 13:34  Camera\Camera\bin\Debug\Debug\AForge.Controls.dll

     文件       9728  2008-11-16 11:45  Camera\Camera\bin\Debug\Debug\AForge.dll

     文件      97792  2008-11-18 10:46  Camera\Camera\bin\Debug\Debug\AForge.Imaging.dll

     文件      27136  2008-10-12 13:34  Camera\Camera\bin\Debug\Debug\AForge.Video.DirectShow.dll

     文件      13312  2008-10-12 13:34  Camera\Camera\bin\Debug\Debug\AForge.Video.dll

     文件      12800  2012-04-21 17:00  Camera\Camera\bin\Debug\Debug\Camera.exe

     文件      24064  2012-04-21 17:00  Camera\Camera\bin\Debug\Debug\Camera.pdb

     文件      11608  2012-04-21 17:03  Camera\Camera\bin\Debug\Debug\Camera.vshost.exe

     文件        490  2010-03-17 22:39  Camera\Camera\bin\Debug\Debug\Camera.vshost.exe.manifest

     文件       2399  2012-09-16 18:32  Camera\Camera\Camera.cs

     文件       4412  2012-09-16 17:54  Camera\Camera\Camera.csproj

     文件       7732  2012-09-16 15:32  Camera\Camera\Camera.Designer.cs

     文件       5817  2012-09-16 15:32  Camera\Camera\Camera.resx

     文件        180  2012-09-16 17:54  Camera\Camera\obj\x86\Debug\Camera.Camera.resources

     文件       1206  2012-09-16 18:32  Camera\Camera\obj\x86\Debug\Camera.csproj.FileListAbsolute.txt

     文件      14848  2012-09-16 18:32  Camera\Camera\obj\x86\Debug\Camera.exe

     文件      46592  2012-09-16 18:32  Camera\Camera\obj\x86\Debug\Camera.pdb

     文件        180  2012-09-16 17:54  Camera\Camera\obj\x86\Debug\Camera.Properties.Resources.resources

     文件       5880  2012-09-16 18:32  Camera\Camera\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        774  2012-09-16 17:54  Camera\Camera\obj\x86\Debug\GenerateResource-ResGen.read.1.tlog

............此处省略27个文件信息

评论

共有 条评论