• 大小: 7.01MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-26
  • 语言: C#
  • 标签: C#  VS2012  视频监控  

资源简介

文件是采用C#开发语言实现视频监控的功能包含录制视频拍照截图存图等

资源截图

代码片段和文件信息

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

namespace AForgenetVideoControlFormBeta
{
    public partial class MainForm : Form
    {
        private VideoCaptureDevice _videoDevice = null;
        private VideoFileWriter _videoWrite = null;

        private string _imagePath = Environment.CurrentDirectory + “\\Images\\“;
        private string _videoPath = Environment.CurrentDirectory + “\\Videos\\“;

        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender EventArgs e)
        {
            //
            if (!Directory.Exists(_imagePath))
                Directory.CreateDirectory(_imagePath);

            if (!Directory.Exists(_videoPath))
                Directory.CreateDirectory(_videoPath);


        }

        private void MainForm_FormClosing(object sender FormClosingEventArgs e)
        {
            if (videoSourcePlayer1.IsRunning)
            {
                videoSourcePlayer1.Stop();

                if (_videoDevice != null)
                    _videoDevice.SignalToStop();
            }
        }

        private void btnOpenVideo_Click(object sender EventArgs e)
        {
            if (videoSourcePlayer1.IsRunning)
                videoSourcePlayer1.Stop();

            VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();
            if (form.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
                return;

            _videoDevice = form.VideoDevice;
            videoSourcePlayer1.VideoSource = form.VideoDevice;
            videoSourcePlayer1.Start();
        }

        private void btnCloseVideo_Click(object sender EventArgs e)
        {
            if (videoSourcePlayer1.IsRunning)
            {
                videoSourcePlayer1.Stop();

                if (_videoDevice != null)
                    _videoDevice.SignalToStop();
            }
        }

        private void btnCapture_Click(object sender EventArgs e)
        {
            if (!videoSourcePlayer1.IsRunning)
                return;

            Bitmap bmp = videoSourcePlayer1.GetCurrentVideoframe();
            string fileName =  DateTime.Now.ToString(“yyyy-MM-dd HH-mm-ss-ff“) + “.jpg“;
            bmp.Save(_imagePath + fileName ImageFormat.Jpeg);
            bmp.Dispose();
        }

        private void btnStartVideotape_Click(object sender EventArgs e)
        {
            string videoFileName = string.Empty;

            //SaveFileDialog saveFile = new SaveFileDialog();
            //saveFile.Filter = “Flash Video(*.flv)|*.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-09-16 22:29  AForgenetVideoControlFormBeta\
     目录           0  2015-09-17 20:51  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\
     文件        6148  2015-09-17 22:24  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta.csproj
     文件         264  2015-09-17 22:28  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\App.config
     文件        7971  2015-09-17 23:28  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\MainForm.Designer.cs
     文件        5391  2015-09-17 23:40  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\MainForm.cs
     文件        5817  2015-09-17 23:28  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\MainForm.resx
     文件         544  2015-09-17 21:00  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\Program.cs
     目录           0  2015-09-16 22:29  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\Properties\
     文件        1378  2015-09-16 22:29  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\Properties\AssemblyInfo.cs
     文件        2898  2015-09-17 22:24  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\Properties\Resources.Designer.cs
     文件        5612  2015-09-16 22:29  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\Properties\Resources.resx
     文件        1129  2015-09-17 22:24  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\Properties\Settings.Designer.cs
     文件         249  2015-09-16 22:29  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\Properties\Settings.settings
     目录           0  2015-09-19 08:54  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\
     目录           0  2015-09-17 21:43  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\
     目录           0  2015-09-19 08:53  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\
     文件       44544  2013-07-15 23:04  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForge.Controls.dll
     文件       16384  2013-07-15 23:04  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForge.Imaging.Formats.dll
     文件      262656  2013-07-15 23:04  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForge.Imaging.dll
     文件       68096  2013-07-15 23:04  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForge.Math.dll
     文件       61440  2013-07-15 23:04  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForge.Video.DirectShow.dll
     文件       61952  2013-07-15 23:07  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForge.Video.FFMPEG.dll
     文件       20992  2013-07-15 23:04  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForge.Video.dll
     文件       17920  2013-07-15 23:04  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForge.dll
     文件       13312  2015-09-17 23:42  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForgenetVideoControlFormBeta.exe
     文件         264  2015-09-17 22:28  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForgenetVideoControlFormBeta.exe.config
     文件       30208  2015-09-17 23:42  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForgenetVideoControlFormBeta.pdb
     文件       22984  2015-09-17 23:43  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForgenetVideoControlFormBeta.vshost.exe
     文件         264  2015-09-17 22:28  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForgenetVideoControlFormBeta.vshost.exe.config
     文件         490  2012-06-02 22:34  AForgenetVideoControlFormBeta\AForgenetVideoControlFormBeta\bin\x86\Debug\AForgenetVideoControlFormBeta.vshost.exe.manifest
............此处省略41个文件信息

评论

共有 条评论