Пример #1
0
 private void frmVideo_Load(object sender, EventArgs e)
 {
     this.Text         = this.MainDevice.Name;
     this.FormClosing += new FormClosingEventHandler(this.frmVideo_FormClosing);
     this.MainThread   = new Thread(new ThreadStart(this.WorkerThread))
     {
         IsBackground = true
     };
     this.MainThread.Start();
     if (this.MainDevice.Type == "File")
     {
         this.groupControl1.Visible    = true;
         this.trackBarControl1.Visible = true;
         BcVideoServer vs = BcVideoServer.LoadById(this.MainDevice.Vsid);
         WcfExtensions.Using <VideoServerClient>(new VideoServerClient(), (Action <VideoServerClient>)(service =>
         {
             service.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)vs.Ip + ":" + (string)(object)vs.Port + "/VideoStreamServer/VideoServer");
             service.Open();
             Thread.Sleep(1000);
             try
             {
                 this.trackBarControl1.Properties.Maximum = (int)service.GetDuration(this.MainDevice.Id);
             }
             catch (Exception ex)
             {
             }
         }));
     }
     else
     {
         this.pictureEdit1.Size = new Size(this.pictureEdit1.Width, this.pictureEdit1.Height + this.groupControl1.Height);
     }
 }
Пример #2
0
        public static void VideoThread(object device)
        {
            BcDevices dev = (BcDevices)device;

            while (!ExtractorServer.StopFlag)
            {
                try
                {
                    if (!dev.IsActive)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }
                    if (dev.Dsid != Guid.Empty)
                    {
                        ExtractorServer.DetectorClientCallback detectorClientCallback = new ExtractorServer.DetectorClientCallback();
                        BcDetectorServer ds = BcDetectorServer.LoadById(dev.Dsid);
                        WcfExtensions.Using <DetectorServerClient>(new DetectorServerClient(new InstanceContext((object)detectorClientCallback)), (Action <DetectorServerClient>)(server =>
                        {
                            server.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)ds.Ip + ":" + (string)(object)ds.Port + "/CSDetectorServer/DetectorServer");
                            server.Open();
                            while (dev.IsActive && !ExtractorServer.StopFlag)
                            {
                                ExtractorServer._logger.Debug((object)string.Format("Request to Detector DevId={0}", (object)dev.Id));
                                FaceFrame lastFrame = server.GetLastFrame(dev.Id);
                                if (lastFrame == null)
                                {
                                    Thread.Sleep(20);
                                }
                                else
                                {
                                    ExtractorServer._logger.Debug((object)string.Format("Response from Detector DevId={0} FrameId={1} FrameIndex={2}", (object)dev.Id, (object)lastFrame.FrameId, (object)lastFrame.FrameIndex));
                                    ExtractorServer._faceframes.Enqueue(lastFrame);
                                }
                            }
                        }));
                    }
                }
                catch (Exception ex)
                {
                    ExtractorServer.Logger.Error((object)"Video Thread error ", ex);
                }
                Thread.Sleep(1000);
            }
        }