Exemple #1
0
 /// <summary>
 /// 改变采集分辨率
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <returns></returns>
 private void cmbCapability_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbCapability.SelectedItem != null)
     {
         if (videoSource != null)
         {
             VideoCapabilitiesItem item = cmbCapability.SelectedItem as VideoCapabilitiesItem;
             videoSource.VideoResolution = item.VideoCapability;
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// 切换视频设备,初始化支持分辨率的列表
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <returns></returns>
 private void cmbSource_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbSource.SelectedIndex >= 0)
     {
         videoSource = new VideoCaptureDevice(videoDevices[cmbSource.SelectedIndex].MonikerString);
         if (!videoSource.CheckIfCrossbarAvailable())
         {
             this.button2.Enabled = false;
         }
         //摄像头的能力
         VideoCapabilities[] vc = videoSource.VideoCapabilities;
         //通过VideoCapabilities可以得到全部能力,然后进行判断设置分辨率
         this.cmbCapability.Items.Clear();
         for (int i = 0; i < vc.Length; i++)
         {
             VideoCapabilitiesItem item = new VideoCapabilitiesItem(vc[i]);
             this.cmbCapability.Items.Add(item);
         }
         this.cmbCapability.SelectedIndex = 0;
     }
 }