示例#1
0
 public void StartCapturing()
 {
     try
     {
         if (CaptureDevice.Equals(""))
         {
             _capture = new Capture();
         }
         else
         {
             if (capturingType.Equals(CaptureType.Local))
             {
                 _capture = new Capture(Convert.ToInt32(CaptureDevice));
             }
             else if (capturingType.Equals(CaptureType.IP))
             {
                 _capture = new Capture(CaptureDevice);
             }
         }
         _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS, 40);
         _capture.ImageGrabbed += ProcessFrame;
         _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);
         _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
         _capture.Start();
         IsCapturing = true;
     }
     catch (Exception) { }
 }
示例#2
0
        public void SwitchVideoFeed(CaptureType type)
        {
            try
            {
                bool switchWhileCapturing = IsCapturing;
                capturingType = type;

                if (IsCapturing)
                {
                    StopCapturing();
                }
                if (type.Equals(CaptureType.MasterFeed))
                {
                    if (!Main.User.ConnectedToMaster)
                    {
                        Main.ShowError("Master is not connected! No video feed.", "Tried to receive Master video feed without a connection to Master. (ChangeVideoSource)");
                    }
                    else
                    {
                        IsListeningForVideo = true;
                        Thread t = new Thread(new ThreadStart(ListenForVideo));
                        t.IsBackground = true;
                        t.Start();
                    }
                }
                else
                {
                    if (!Main.User.IsMaster)
                    {
                        IsListeningForVideo = false;
                    }

                    if (switchWhileCapturing || !Main.User.IsMaster)
                    {
                        StartCapturing();
                    }
                }
                capturingType = type;
            }
            catch (Exception ex)
            {
                Main.ShowError(ex.Message, ex.ToString());
            }
        }
        public void SwitchVideoFeed(CaptureType type)
        {
            try
            {
                bool switchWhileCapturing = IsCapturing;
                capturingType = type;

                if (IsCapturing)
                    StopCapturing();
                if (type.Equals(CaptureType.MasterFeed))
                {
                    if (!Main.User.ConnectedToMaster)
                        Main.ShowError("Master is not connected! No video feed.", "Tried to receive Master video feed without a connection to Master. (ChangeVideoSource)");
                    else
                    {
                        IsListeningForVideo = true;
                        Thread t = new Thread(new ThreadStart(ListenForVideo));
                        t.IsBackground = true;
                        t.Start();
                    }
                }
                else
                {
                    if (!Main.User.IsMaster)
                        IsListeningForVideo = false;

                    if (switchWhileCapturing || !Main.User.IsMaster)
                        StartCapturing();
                }
                capturingType = type;
            }
            catch (Exception ex)
            {
                Main.ShowError(ex.Message, ex.ToString());
            }
        }