zoukankan      html  css  js  c++  java
  • Aforge视频采集

     /// <summary>
            /// 获取视频采集设备列表
            /// </summary>
            private void GetCameraList()
            {
                try
                {
                    videoDeviceCoolection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                    if (videoDeviceCoolection.Count == 0)
                    { 
                        throw new ApplicationException();
                    }
                    DeviceExits = true;
                    foreach (FilterInfo item in videoDeviceCoolection)
                    {
                        comboBoxDevices.Items.Add(item.Name);
                    }
                    comboBoxDevices.SelectedIndex = 0;
    
    
                }
                catch (ApplicationException)
                {
                    DeviceExits = false;
                    MessageBox.Show("Not Find VedioDevice!");
                }
                
    
            }
    
    
            /// <summary>
            /// 播放视频帧
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="eventArgs"></param>
            private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
            {
                Bitmap bit =  (Bitmap)eventArgs.Frame.Clone();
                pictureBox1.Image = bit;
                pictureBox1.Refresh();
            }
    
            /// <summary>
            /// 播放采集的视频
            /// </summary>
            private void PlayVideo()
            {
                videoDevice = new VideoCaptureDevice(videoDeviceCoolection[comboBoxDevices.SelectedIndex].MonikerString);
                videoDevice.NewFrame += new NewFrameEventHandler(video_NewFrame);
                videoDevice.DesiredFrameSize = new Size(pictureBox1.Width,pictureBox1.Height);
                videoDevice.Start();
            }
      private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
            {
                Bitmap bit = (Bitmap)eventArgs.Frame.Clone();
                Bitmap cloned = (Bitmap)(bit.Clone());
                GC.Collect();
                pictureBox1.Image = bit;
               // Thread resultThread = new Thread(new ThreadStart(GetResult));
                Thread resultThread = new Thread(new ThreadStart(delegate { GetResult(cloned); }));
                resultThread.Start();
                //resultThread.Start((Bitmap)bit.Clone());
                //GetResult(cloned);
    
                //GetResultDelegate re = GetResult;
                //IAsyncResult result = re.BeginInvoke(cloned, null, null);
    
                //Thread th = new Thread(new ParameterizedThreadStart(GetResult));
                //th.Start(bit);
            }
  • 相关阅读:
    国外C#开源系统一览表
    国外的开源的CMS系统(ASP.Net_c#)
    CSS简写方法说明
    比较著名的.net技术论坛网址(含国外的)
    :domino用户的新邮件不出现在$Inbox(收件箱),但可以在'所有文档'视图中看到
    Domino邮件记录
    Lotus notes685升级安装设置
    Lotus 与 Exchange 对比评测
    Domino维护与监控
    用户在notes和shmail禁用离开办公室后,为何离开办公室代理依然运行
  • 原文地址:https://www.cnblogs.com/liuxinls/p/2871170.html
Copyright © 2011-2022 走看看