资源简介


资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing.Imaging;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.IO;
using System.Windows.Media.Imaging;
using AForge;
using AForge.Controls;
using AForge.Video;
using AForge.Video.DirectShow;
using Size = System.Drawing.Size;


namespace OperateCamera
{
    public partial class Form1 : Form
    {
        private FilterInfoCollection videoDevices;
        private VideoCaptureDevice videoSource;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            
            try
            {
                // 枚举所有视频输入设备
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                foreach (FilterInfo device in videoDevices)
                {
                    tscbxCameras.Items.Add(device.Name);
                }

                tscbxCameras.SelectedIndex = 0;

            }
            catch (ApplicationException)
            {
                tscbxCameras.Items.Add(“No local capture devices“);
                videoDevices = null;
            }
        }

        private void btnConnect_Click(object sender EventArgs e)
        {
            CameraConn();
           
        }
        //连接摄像头
        private void CameraConn()
        {
            VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[tscbxCameras.SelectedIndex].MonikerString);
            videoSource.DesiredframeSize = new System.Drawing.Size(320 240);
            videoSource.DesiredframeRate = 1;

            videoSourcePlayer.VideoSource = videoSource;
            videoSourcePlayer.Start();
        }

        //关闭摄像头
        private void btnClose_Click(object sender EventArgs e)
        {
            videoSourcePlayer.SignalToStop();
            videoSourcePlayer.WaitForStop();
        }

        //主窗体关闭
        private void Form1_FormClosing(object sender FormClosingEventArgs e)
        {
            btnClose_Click(null null);
        }

        //拍照
        private void Photograph_Click(object sender EventArgs e)
        {
            try
            {
                if (videoSourcePlayer.IsRunning)
                {
                    BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                                    videoSourcePlayer.GetCurrentVideoframe().GetHbitmap()
                                    IntPtr.Zero
                                     Int32Rect.Empty
                                    BitmapSizeOptions.FromEmptyOptions());
                    PngBitmapEncoder pE = new PngBitmapEncoder();
                    pE.frames

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

     文件       3106  2018-06-22 09:42  51asp.net源码申明.txt

     文件        110  2018-06-22 09:43  asp.net免费源码下载.url

     文件       4468  2014-02-17 00:08  Form1.cs

     文件       5322  2014-02-17 00:08  Form1.Designer.cs

     文件       5817  2014-02-17 00:08  Form1.resx

     文件       4450  2014-02-16 21:16  OperateCamera.csproj

     文件        227  2014-02-16 20:18  OperateCamera.csproj.user

     文件        494  2014-02-16 17:21  Program.cs

     文件      10297  2014-04-22 16:54  QQ截图20140422165424.png

     文件      44544  2013-07-15 23:04  bin\Debug\AForge.Controls.dll

     文件      17920  2013-07-15 23:04  bin\Debug\AForge.dll

     文件     262656  2013-07-15 23:04  bin\Debug\AForge.Imaging.dll

     文件      61440  2013-07-15 23:04  bin\Debug\AForge.Video.DirectShow.dll

     文件      20992  2013-07-15 23:04  bin\Debug\AForge.Video.dll

     文件      12288  2014-04-22 16:53  bin\Debug\OperateCamera.exe

     文件      30208  2014-04-22 16:53  bin\Debug\OperateCamera.pdb

     文件      11600  2014-04-22 16:54  bin\Debug\OperateCamera.vshost.exe

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

     文件      44544  2013-07-15 23:04  lib\AForge.Controls.dll

     文件      17920  2013-07-15 23:04  lib\AForge.dll

     文件     262656  2013-07-15 23:04  lib\AForge.Imaging.dll

     文件      61440  2013-07-15 23:04  lib\AForge.Video.DirectShow.dll

     文件      20992  2013-07-15 23:04  lib\AForge.Video.dll

     文件       2152  2014-02-16 17:21  obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6973  2014-04-22 16:53  obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        590  2014-04-22 16:53  obj\x86\Debug\GenerateResource.read.1.tlog

     文件       1426  2014-04-22 16:53  obj\x86\Debug\GenerateResource.write.1.tlog

     文件       2876  2014-04-22 16:54  obj\x86\Debug\OperateCamera.csproj.FileListAbsolute.txt

     文件      12288  2014-04-22 16:53  obj\x86\Debug\OperateCamera.exe

     文件        180  2014-04-22 16:53  obj\x86\Debug\OperateCamera.Form1.resources

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

评论

共有 条评论