• 大小: 253KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: C#
  • 标签: C#  WinFo  Direct  抓拍  

资源简介

C# WinForm DirectShow视频采集及图片抓取实例DxSnap 抓拍 视频

资源截图

代码片段和文件信息

/****************************************************************************
While the underlying libraries are covered by LGPL this sample is released 
as public domain.  It is distributed in the hope that it will be useful but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE.  
*****************************************************************************/

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.Runtime.InteropServices;
using System.Threading;
using System.Diagnostics;
using System.Windows.Forms;

using DirectShowLib;


namespace SnapShot
{
    ///  Summary description for MainForm. 
    internal class Capture : ISampleGrabberCB IDisposable
    {
        #region Member variables

        ///  graph builder interface. 
        private IFilterGraph2 m_FilterGraph = null;

        // Used to snap picture on Still pin
        private IAMVideoControl m_VidControl = null;
        private IPin m_pinStill = null;

        ///  so we can wait for the async job to finish 
        private ManualResetEvent m_PictureReady = null;

        private bool m_WantOne = false;

        ///  Dimensions of the image calculated once in constructor for perf. 
        private int m_videoWidth;
        private int m_videoHeight;
        private int m_stride;

        ///  buffer for bitmap data.  Always release by caller
        private IntPtr m_ipBuffer = IntPtr.Zero;

#if DEBUG
        // Allow you to “Connect to remote graph“ from GraphEdit
        DsROTEntry m_rot = null;
#endif
        #endregion

        #region APIs
        [DllImport(“Kernel32.dll“ EntryPoint = “RtlMoveMemory“)]
        private static extern void CopyMemory(IntPtr Destination IntPtr Source [MarshalAs(UnmanagedType.U4)] int Length);
        #endregion

        // Zero based device index and device params and output window
        public Capture(int iDeviceNum int iWidth int iHeight short iBPP Control hControl)
        {
            DsDevice[] capDevices;

            // Get the collection of video devices
            capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);

            if (iDeviceNum + 1 > capDevices.Length)
            {
                throw new Exception(“No video capture devices found at that index!“);
            }

            try
            {
                // Set up the capture graph
                SetupGraph(capDevices[iDeviceNum] iWidth iHeight iBPP hControl);

                // tell the callback to ignore new images
                m_PictureReady = new ManualResetEvent(false);
            }
            catch
            {
                Dispose();
                throw;
            }
        }

        /// 
 release everyt

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

     文件        187  2019-04-29 23:06  DirectShowDxSnap\WindowsFormsApplication1\App.config

     文件     312320  2016-07-08 20:24  DirectShowDxSnap\WindowsFormsApplication1\bin\Debug\DirectShowLib-2005.dll

     文件      16896  2019-04-30 10:06  DirectShowDxSnap\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件        187  2019-04-29 23:06  DirectShowDxSnap\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config

     文件      32256  2019-04-30 10:06  DirectShowDxSnap\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      23168  2019-04-30 10:09  DirectShowDxSnap\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        187  2019-04-29 23:06  DirectShowDxSnap\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.config

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

     文件      18864  2019-04-30 09:12  DirectShowDxSnap\WindowsFormsApplication1\Capture.cs

     文件       3983  2019-04-29 23:13  DirectShowDxSnap\WindowsFormsApplication1\DirectShowDxSnap.csproj

     文件     312320  2016-07-08 20:24  DirectShowDxSnap\WindowsFormsApplication1\DirectShowLib-2005.dll

     文件       6899  2019-04-30 10:06  DirectShowDxSnap\WindowsFormsApplication1\Form1.cs

     文件       4617  2019-04-30 09:15  DirectShowDxSnap\WindowsFormsApplication1\Form1.Designer.cs

     文件       5817  2019-04-30 09:53  DirectShowDxSnap\WindowsFormsApplication1\Form1.resx

     文件        865  2019-04-29 23:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7096  2019-04-30 09:03  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        879  2019-04-30 10:09  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\DirectShowDxSnap.csproj.FileListAbsolute.txt

     文件        977  2019-04-30 10:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\DirectShowDxSnap.csproj.GenerateResource.Cache

     文件        180  2019-04-30 10:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\SnapShot.Form1.resources

     文件          0  2019-04-29 23:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2019-04-29 23:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2019-04-29 23:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件       1162  2019-04-30 09:02  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件        977  2019-04-30 09:01  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件       6691  2019-04-29 23:13  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache

     文件      16896  2019-04-30 10:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe

     文件      32256  2019-04-30 10:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb

     文件        180  2019-04-30 10:06  DirectShowDxSnap\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件        520  2019-04-29 23:13  DirectShowDxSnap\WindowsFormsApplication1\Program.cs

     文件       1372  2019-04-29 23:06  DirectShowDxSnap\WindowsFormsApplication1\Properties\AssemblyInfo.cs

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

评论

共有 条评论