示例#1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (streamLocCam.Checked == true)
     {
         if (button2.Text == "Start Camera")
         {
             kamera           = new VideoCaptureDevice(webCams[comboBox1.SelectedIndex].MonikerString);
             kamera.NewFrame += new NewFrameEventHandler(video_NewFrame);
             kamera.Start();
             button2.Text = "Stop Camera";
         }
         else
         {
             kamera.SignalToStop();
             kamera       = null;
             button2.Text = "Start Camera";
         }
     }
     else
     {
         if (button2.Text == "Start Camera")
         {
             stream           = new MJPEGStream("http://" + inputIP.Text + "/video");
             stream.NewFrame += new NewFrameEventHandler(video_NewFrame);
             stream.Start();
             button2.Text = "Stop Camera";
         }
         else
         {
             stream.SignalToStop();
             stream       = null;
             button2.Text = "Start Camera";
         }
     }
 }
示例#2
0
        private void btn_playPause_Click(object sender, EventArgs e)
        {
            i++;
            if (i % 2 == 0)
            {
                this.btn_playPause.Image = ((System.Drawing.Image)(Properties.Resources.playIcon));

                btn_capImage.Enabled = false;
                videoSource.SignalToStop();
                videoSource.WaitForStop();
                videoSource.Stop();
            }
            else
            {
                new Thread(() => {
                    Thread.CurrentThread.IsBackground = true;
                    btn_capImage.Enabled     = true;
                    videoSource.Login        = camUsername;
                    videoSource.Password     = camPassword;
                    this.btn_playPause.Image = ((System.Drawing.Image)(Properties.Resources.pauseIcon));
                    videoSource.NewFrame    += new NewFrameEventHandler(video_NewFrame);
                    videoSource.Start();
                }).Start();
            }
        }
示例#3
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);

            if (Keyboard [Key.Escape])
            {
                Exit();
            }
            if (Keyboard [Key.S])
            {
                videoStream.SignalToStop();
            }
        }
示例#4
0
 /// <summary>
 /// Funkcja zatrzymująca działanie kamery.
 /// </summary>
 public void StopCamera()
 {
     if (stream == null)
     {
         return;
     }
     else if (stream.IsRunning)
     {
         stream.SignalToStop();
     }
 }
示例#5
0
        private void StopVideo(int cam)
        {
            switch (cam)
            {
            case 0:
                vspTarget.SignalToStop();
                vspTarget.WaitForStop();
                videoSource.SignalToStop();
                videoSource.WaitForStop();
                break;

            case 1:
            case 2:
            case 3:
                vspTarget.SignalToStop();
                vspTarget.WaitForStop();
                stream.SignalToStop();
                stream.WaitForStop();
                break;
            }
            btnCapture.Text    = "Start";
            capVideoInProgress = false;
            cmbCamera.Enabled  = true;
        }
示例#6
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     stream.SignalToStop();
     stream.Stop();
 }
示例#7
0
 void stream_VideoError(object sender, VideoSourceErrorEventArgs eventArgs)
 {
     stream.SignalToStop();
     workCamera = false;
     MessageBox.Show("Connect camera fail!! " + eventArgs.Description);
 }
示例#8
0
 public void SignalToStop()
 {
     client.SignalToStop();
 }