• 大小: 32.71MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-14
  • 语言: 其他
  • 标签:

资源简介

基于AForge.Net调用本机摄像头进行拍照,附带AForge.Net下载

资源截图

代码片段和文件信息

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;
using AForge;
using AForge.Video;
using AForge.Imaging;
using AForge.Controls;
using AForge.Video.DirectShow;
using System.Drawing.Imaging;

namespace VideoCapture
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        FilterInfoCollection videoDevices;
        VideoCaptureDevice videoSource;
        public int selectedDeviceIndex = 0;        
        private void button1_Click(object sender EventArgs e)
        {
            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            selectedDeviceIndex = 0;
            videoSource = new VideoCaptureDevice(videoDevices[selectedDeviceIndex].MonikerString);//连接摄像头。
            videoSource.VideoResolution = videoSource.VideoCapabilities[selectedDeviceIndex];
            videoSourcePlayer1.VideoSource = videoSource;
            // set Newframe event handler
            videoSourcePlayer1.Start();
        }
        private void videoSourcePlayer1_Click(object sender EventArgs e)
        {

        }

        private void button2_Click_1(object sender EventArgs e)
        {
            if (videoSource == null)
            return;
            Bitmap bitmap = videoSourcePlayer1.GetCurrentVideoframe();
            string fileName = “54250.jpg“;//DateTime.Now.ToString(“yyyy-MM-dd-HH-mm-ss-ff“) + “.jpg“;
            bitmap.Save(@“E:\temp\“ + fileName ImageFormat.Jpeg);
            bitmap.Dispose();
        }
        private void Form1_FormClosed(object sender FormClosedEventArgs e)
        {
           
                videoSourcePlayer1.Stop();
                videoSourcePlayer1.Dispose();
            
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件    33834677  2018-04-23 09:09  VideoCapture\AForge.NET framework-2.2.5.exe
     目录           0  2018-04-23 18:05  VideoCapture\VideoCapture\
     目录           0  2018-04-23 18:00  VideoCapture\VideoCapture\.vs\
     目录           0  2018-04-23 18:00  VideoCapture\VideoCapture\.vs\VideoCapture\
     目录           0  2018-04-23 18:01  VideoCapture\VideoCapture\.vs\VideoCapture\v15\
     文件       53760  2018-04-23 18:03  VideoCapture\VideoCapture\.vs\VideoCapture\v15\.suo
     目录           0  2018-04-23 18:01  VideoCapture\VideoCapture\.vs\VideoCapture\v15\Server\
     目录           0  2018-04-23 18:03  VideoCapture\VideoCapture\.vs\VideoCapture\v15\Server\sqlite3\
     文件           0  2018-04-23 18:01  VideoCapture\VideoCapture\.vs\VideoCapture\v15\Server\sqlite3\db.lock
     文件       32768  2018-04-23 18:03  VideoCapture\VideoCapture\.vs\VideoCapture\v15\Server\sqlite3\storage.ide
     目录           0  2018-04-23 09:26  VideoCapture\VideoCapture\.vs\图像处理\
     目录           0  2018-04-23 18:00  VideoCapture\VideoCapture\.vs\图像处理\v15\
     目录           0  2018-04-23 09:27  VideoCapture\VideoCapture\.vs\图像处理\v15\Server\
     目录           0  2018-04-23 18:00  VideoCapture\VideoCapture\.vs\图像处理\v15\Server\sqlite3\
     文件        1135  2018-04-23 18:00  VideoCapture\VideoCapture\VideoCapture.sln
     目录           0  2018-04-23 18:03  VideoCapture\VideoCapture\VideoCapture\
     文件         189  2018-04-23 09:26  VideoCapture\VideoCapture\VideoCapture\App.config
     目录           0  2018-04-23 17:59  VideoCapture\VideoCapture\VideoCapture\bin\
     目录           0  2018-04-23 18:03  VideoCapture\VideoCapture\VideoCapture\bin\Debug\
     文件       44544  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Controls.dll
     文件       66108  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Controls.xml
     文件       17920  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.dll
     文件      262656  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Imaging.dll
     文件      944046  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Imaging.xml
     文件       68096  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Math.dll
     文件      270650  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Math.xml
     文件       61440  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Video.DirectShow.dll
     文件      195287  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Video.DirectShow.xml
     文件       20992  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Video.dll
     文件       53275  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.Video.xml
     文件       78375  2013-07-15 23:04  VideoCapture\VideoCapture\VideoCapture\bin\Debug\AForge.xml
............此处省略41个文件信息

评论

共有 条评论