新增windows Form控制項程式庫

image

加入參考 DirectShowLib-2005.dll

我是安裝在 C:\CSharp\DirectShowNet\DirectShowLibV2-1\lib

image

專案加入新項目 Public.cs

image

   1: struct videoDevice
   2: {
   3:     public string m_devName;
   4:     public int m_devID;
   5:     public Guid m_identifier;
   6:  
   7:     public videoDevice(int ID, string Name, Guid Identity = new Guid())
   8:     {
   9:         m_devID = ID;
  10:         m_devName = Name;
  11:         m_identifier = Identity;
  12:     }
  13:     public override string ToString()
  14:     {
  15:         return string.Format("[ {0} ] {1} : {2}", m_devID, m_devName, m_identifier);
  16:     }
  17: }

----------------------------------------------------------------------------------------------------------------------------------------------

image

image

image

   1: // 搜尋裝置
   2:        private void LookforDevice()
   3:        {
   4:            int numCameras;
   5:            videoDevice[] vidDev;
   6:            // 透過DirectShow抓取照相機數量
   7:            DsDevice[] DSDev = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);  
   8:            numCameras = DSDev.Length;                // 照相機數量
   9:  
  10:            if (numCameras > 0)                       // 有照相機
  11:            {
  12:                comboBox1.Items.Clear();          
  13:                vidDev = new videoDevice[numCameras]; // 初始化
  14:                for (int i = 0; i < numCameras; i++)
  15:                {
  16:                    // ID, devName, Identity
  17:                    vidDev[i] = new videoDevice(i, DSDev[i].Name, DSDev[i].ClassID);
  18:                    comboBox1.Items.Add(vidDev[i].ToString());
  19:                }
  20:            }
  21:        }
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()